Skip to content

Commit

Permalink
feat: add several profiles&modules
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Oct 27, 2023
1 parent cd611b3 commit 177ddb3
Show file tree
Hide file tree
Showing 32 changed files with 1,444 additions and 102 deletions.
41 changes: 37 additions & 4 deletions docs/org/homeProfiles.org
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,57 @@
** shell

#+begin_src nix :tangle (concat (org-entry-get nil "PRJ-DIR" t) "/shell.nix")
{ root }:
{
root,
self,
lib,
inputs,
}:
let
presets = root.presets;
inherit (inputs) nixpkgs;
in
with presets; {
minimal = [
direnv
git
];
default = [
self.minimal
self.modernTools
self.utils
# ------------------------------
zoxide
fzf
direnv
dircolors
starship.default
dircolors.default
];

fileManager = [
yazi
broot
];

fileManager = [ yazi ];
full = [
self.default
# ------------------------------
spell-check
self.fileManager
(lib.optionals nixpkgs.stdenv.isLinux presets.alacritty)
];

modernTools = [
pls
# eza
];

utils = [
{
programs.btop.enable = true;
programs.bat.enable = true;
programs.jq.enable = true;
}
];
}
#+end_src

Expand Down
2 changes: 1 addition & 1 deletion docs/org/nixosProfiles.org
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ with presets; {
coding.nix
];

full = [
coding = [
self.default
{
config.omnibus.coding = {
Expand Down
13 changes: 13 additions & 0 deletions lib/addLoadToPops.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ lib }:
list: pops: load:
lib.listToAttrs (
map
(name: {
inherit name;
value =
lib.mapAttrs
(n: v: if v ? addLoadExtender then v.addLoadExtender (load name n v) else v)
pops;
})
list
)
9 changes: 6 additions & 3 deletions lib/exporter/pops.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
let
baseInputs = {
inherit omnibus POP flops;
inherit
omnibus
POP
flops
lib
;
inputs = {
inherit (inputs) dmerge;
inherit lib;
};
};
in
Expand Down Expand Up @@ -43,7 +47,6 @@ in
homeProfiles = self.homeModules.addLoadExtender {
load = {
src = inputs.self.outPath + "/units/nixos/homeProfiles";
loader = haumea.loaders.scoped;
type = "nixosProfiles";
transformer = [ (_: _: _) ];
};
Expand Down
5 changes: 5 additions & 0 deletions lib/mapLoadToPops.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ lib }:
pops: load:
lib.mapAttrsRecursiveCond ((as: !(as ? "addLoadExtender")))
(n: v: v.addLoadExtender (load n v))
pops
2 changes: 1 addition & 1 deletion lib/mapPopsLayouts'.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ lib }:
pops:
lib.mapAttrsRecursiveCond ((as: !(as ? "layouts"))) (_: v: v.layouts or v) pops
lib.mapAttrsRecursiveCond ((as: !(as ? "layouts"))) (_: v: v.layouts) pops
23 changes: 23 additions & 0 deletions lib/mapPopsLayouts.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
{ lib }:
pops:
let
in
# mapAttrsRecursiveCond' =
# cond: f: set:
# let
# recurse =
# path: set:
# let
# g =
# name: value:
# if lib.isAttrs value && cond value then
# { ${name} = recurse (path ++ [ name ]) value; }
# else
# f (path ++ [ name ]) name value;
# in
# mapAttrs'' g set;
# in
# recurse [ ] set;
# mapAttrs'' =
# f: set:
# lib.foldl' (a: b: a // b) { } (
# map (attr: f attr set.${attr}) (lib.attrNames set)
# );
lib.mapAttrsRecursiveCond ((as: !(as ? "layouts" && as.layouts ? "default")))
(_: v: v.layouts.default or v)
pops
4 changes: 2 additions & 2 deletions lib/mkHome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ in
home-manager.useUserPackages = lib.mkDefault true;

home-manager.users.${user} = {
imports = lib.flatten suites;
imports = lib.flatten [ suites ];
home.stateVersion =
if pkgs.stdenv.isDarwin then pkgs.lib.trivial.release else "23.11";
};
programs.${shell}.enable = true;
users.users.${user} = {
shell = pkgs."${shell}";
home = if pkgs.stdenv.isDarwin then "/Users/${user}" else "/home/${user}";
};
programs.${shell}.enable = true;
}
)
]
Expand Down
25 changes: 8 additions & 17 deletions templates/hivebus/nix/lib/exporter/pops/hosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@
lib,
inputs,
super,
omnibus,
root,
}:
let
hostsDir = lib.attrNames (
lib.readDir (inputs.self.outPath + "/units/nixos/hosts")
);
inherit (omnibus.lib) addLoadToPops;
in
lib.listToAttrs (
map
(name: {
inherit name;
value =
lib.mapAttrs
(
n: v:
v.addLoadExtender {
load.src =
root.filterPopsSrc (inputs.self.outPath + "/units/nixos/hosts/${name}")
n;
}
)
super.hostsLoad;
})
hostsDir
addLoadToPops hostsDir super.hostsLoad (
elm: n: v: {
load.src =
root.filterPopsSrc (inputs.self.outPath + "/units/nixos/hosts/${elm}")
n;
}
)
25 changes: 8 additions & 17 deletions templates/nixos/nix/lib/exporter/pops/hosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@
lib,
inputs,
super,
omnibus,
root,
}:
let
hostsDir = lib.attrNames (
lib.readDir (inputs.self.outPath + "/units/nixos/hosts")
);
inherit (omnibus.lib) addLoadToPops;
in
lib.listToAttrs (
map
(name: {
inherit name;
value =
lib.mapAttrs
(
n: v:
v.addLoadExtender {
load.src =
root.filterPopsSrc (inputs.self.outPath + "/units/nixos/hosts/${name}")
n;
}
)
super.hostsLoad;
})
hostsDir
addLoadToPops hostsDir super.hostsLoad (
elm: n: v: {
load.src =
root.filterPopsSrc (inputs.self.outPath + "/units/nixos/hosts/${elm}")
n;
}
)
13 changes: 0 additions & 13 deletions units/nixos/darwinModules/omnibus/bootstrap/default.nix

This file was deleted.

14 changes: 14 additions & 0 deletions units/nixos/darwinProfiles/init.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
root,
self,
super,
}:
let
presets = super.presets;
in
with presets; {
default = [
bootstrap
{ omnibus.bootstrap.minimal = true; }
];
}
2 changes: 1 addition & 1 deletion units/nixos/darwinProfiles/presets/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
cfg = config.omnibus.bootstrap;
in
{
imports = [ omnibus.darwinModules.bootstrap ];
imports = [ omnibus.nixosModules.omnibus.bootstrap ];
config = {
omnibus.bootstrap.PATH = lib.mkBefore [
"/run/current-system/sw/bin"
Expand Down
42 changes: 4 additions & 38 deletions units/nixos/darwinProfiles/presets/homebrew.nix
Original file line number Diff line number Diff line change
@@ -1,48 +1,14 @@
{
omnibus,
pkgs,
lib,
}:
let
inherit (pkgs.stdenv.hostPlatform) isAarch64;
brewPrefix = if isAarch64 then "/opt/homebrew" else "/usr/local";
in
{ omnibus, lib }:
{
imports = [ omnibus.darwinModules.homebrew ];

# credit: https://github.com/montchr/dotfield/blob/dd5e577d91b1af7f13909f5dc4343717a718ff02/darwin/profiles/core/default.nix
homebrew = {
enable = true;
# onActivation.cleanup = "zap";
onActivation.upgrade = lib.mkDefault true;
# Use the nix-darwin brewfile when invoking `brew bundle` imperatively.
global.brewfile = lib.mkDefault true;
global.lockfiles = lib.mkDefault false;
__profiles__ = {
readers = lib.mkDefault true;
shell = lib.mkDefault true;
containers = lib.mkDefault true;
security = lib.mkDefault true;
chat = lib.mkDefault true;
casks.removePackagesFromProfiles = [ ];
brews.removePackagesFromProfiles = [ ];
};
};
# <https://github.com/LnL7/nix-darwin/issues/596>
#
# $ brew shellenv
# export HOMEBREW_PREFIX="/opt/homebrew";
# export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
# export HOMEBREW_REPOSITORY="/opt/homebrew";
# export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
# export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
# export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
environment.systemPath = lib.mkBefore [
"${brewPrefix}/bin"
"${brewPrefix}/sbin"
];
environment.variables = {
HOMEBREW_PREFIX = brewPrefix;
HOMEBREW_CELLAR = "${brewPrefix}/Cellar";
HOMEBREW_REPOSITORY = brewPrefix;
MANPATH = "${brewPrefix}/share/man:$MANPATH";
INFOPATH = "${brewPrefix}/share/info:$INFOPATH";
};
}
18 changes: 18 additions & 0 deletions units/nixos/homeModules/programs/alacritty/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let
CSIuKeyBindings =
(builtins.fromTOML (builtins.readFile ./key-bindings.toml)).key_bindings;
in
{
options = {
CSIuSupport = lib.mkEnableOption "Enable CSIu support";
};
config = mkMerge [
(mkIf (cfg.enable && pkgs.stdenv.isLinux) {
programs.alacritty = {
settings = {
key_bindings = mkIf cfg.CSIuSupport CSIuKeyBindings;
};
};
})
];
}
Loading

0 comments on commit 177ddb3

Please sign in to comment.