refactor: package and module generation

This commit is contained in:
Swarsel 2024-12-10 22:51:13 +01:00
parent 3a272b1fe6
commit 2cf03a3243
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
4 changed files with 131 additions and 77 deletions

View file

@ -1533,25 +1533,31 @@ This is the central station for self-defined packages. These are all referenced
#+begin_src nix :tangle pkgs/default.nix #+begin_src nix :tangle pkgs/default.nix
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs) callPackage; packageNames = [
"pass-fuzzel"
"cura5"
"hm-specialisation"
"cdw"
"cdb"
"bak"
"timer"
"e"
"swarselcheck"
"waybarupdate"
"opacitytoggle"
"fs-diff"
"update-checker"
"github-notifications"
"screenshare"
"bootstrap"
];
mkPackages = names: builtins.listToAttrs (map (name: {
inherit name;
value = pkgs.callPackage ./${name} { };
}) names);
in in
{ mkPackages packageNames
pass-fuzzel = callPackage ./pass-fuzzel { };
cura5 = callPackage ./cura5 { };
hm-specialisation = callPackage ./hm-specialisation { };
cdw = callPackage ./cdw { };
cdb = callPackage ./cdb { };
bak = callPackage ./bak { };
timer = callPackage ./timer { };
e = callPackage ./e { };
swarselcheck = callPackage ./swarselcheck { };
waybarupdate = callPackage ./waybarupdate { };
opacitytoggle = callPackage ./opacitytoggle { };
fs-diff = callPackage ./fs-diff { };
update-checker = callPackage ./update-checker { };
github-notifications = callPackage ./github-notifications { };
screenshare = callPackage ./screenshare { };
}
#+end_src #+end_src
@ -2349,14 +2355,24 @@ In this section I define custom modules under the =swarsel= attribute. These are
Modules that need to be loaded on the NixOS level. Note that these will not be available on systems that are not running NixOS Modules that need to be loaded on the NixOS level. Note that these will not be available on systems that are not running NixOS
#+begin_src nix :tangle modules/nixos/default.nix #+begin_src nix :tangle modules/nixos/default.nix
{ let
wallpaper = import ./wallpaper.nix; moduleNames = [
hardware = import ./hardware.nix; "wallpaper"
setup = import ./setup.nix; "hardware"
impermanence = import ./impermanence.nix; "setup"
filesystem = import ./filesystem.nix; "impermanence"
input = import ./input.nix; "filesystem"
} "input"
];
mkImports = names: builtins.listToAttrs (map (name: {
inherit name;
value = import ./${name}.nix;
}) names);
in
mkImports moduleNames
#+end_src #+end_src
@ -2493,18 +2509,27 @@ This lets me quickly set flags for "special" file systems. These options mostly
This holds modules that are to be used on most hosts. These are also the most important options to configure, as these allow me easy access to monitor, keyboard, and other setups. This holds modules that are to be used on most hosts. These are also the most important options to configure, as these allow me easy access to monitor, keyboard, and other setups.
#+BEGIN_src nix :tangle modules/home/default.nix #+BEGIN_src nix :tangle modules/home/default.nix
{ let
laptop = import ./laptop.nix; moduleNames = [
hardware = import ./hardware.nix; "laptop"
monitors = import ./monitors.nix; "hardware"
input = import ./input.nix; "monitors"
nixos = import ./nixos.nix; "input"
darwin = import ./darwin.nix; "nixos"
waybar = import ./waybar.nix; "darwin"
startup = import ./startup.nix; "waybar"
wallpaper = import ./wallpaper.nix; "startup"
filesystem = import ./filesystem.nix; "wallpaper"
} "filesystem"
];
mkImports = names: builtins.listToAttrs (map (name: {
inherit name;
value = import ./${name}.nix;
}) names);
in
mkImports moduleNames
#+end_src #+end_src
***** Laptop ***** Laptop

View file

@ -1,12 +1,23 @@
{ let
laptop = import ./laptop.nix; moduleNames = [
hardware = import ./hardware.nix; "laptop"
monitors = import ./monitors.nix; "hardware"
input = import ./input.nix; "monitors"
nixos = import ./nixos.nix; "input"
darwin = import ./darwin.nix; "nixos"
waybar = import ./waybar.nix; "darwin"
startup = import ./startup.nix; "waybar"
wallpaper = import ./wallpaper.nix; "startup"
filesystem = import ./filesystem.nix; "wallpaper"
} "filesystem"
];
mkImports = names: builtins.listToAttrs (map
(name: {
inherit name;
value = import ./${name}.nix;
})
names);
in
mkImports moduleNames

View file

@ -1,8 +1,19 @@
{ let
wallpaper = import ./wallpaper.nix; moduleNames = [
hardware = import ./hardware.nix; "wallpaper"
setup = import ./setup.nix; "hardware"
impermanence = import ./impermanence.nix; "setup"
filesystem = import ./filesystem.nix; "impermanence"
input = import ./input.nix; "filesystem"
} "input"
];
mkImports = names: builtins.listToAttrs (map
(name: {
inherit name;
value = import ./${name}.nix;
})
names);
in
mkImports moduleNames

View file

@ -1,21 +1,28 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs) callPackage; packageNames = [
"pass-fuzzel"
"cura5"
"hm-specialisation"
"cdw"
"cdb"
"bak"
"timer"
"e"
"swarselcheck"
"waybarupdate"
"opacitytoggle"
"fs-diff"
"update-checker"
"github-notifications"
"screenshare"
"bootstrap"
];
mkPackages = names: builtins.listToAttrs (map
(name: {
inherit name;
value = pkgs.callPackage ./${name} { };
})
names);
in in
{ mkPackages packageNames
pass-fuzzel = callPackage ./pass-fuzzel { };
cura5 = callPackage ./cura5 { };
hm-specialisation = callPackage ./hm-specialisation { };
cdw = callPackage ./cdw { };
cdb = callPackage ./cdb { };
bak = callPackage ./bak { };
timer = callPackage ./timer { };
e = callPackage ./e { };
swarselcheck = callPackage ./swarselcheck { };
waybarupdate = callPackage ./waybarupdate { };
opacitytoggle = callPackage ./opacitytoggle { };
fs-diff = callPackage ./fs-diff { };
update-checker = callPackage ./update-checker { };
github-notifications = callPackage ./github-notifications { };
screenshare = callPackage ./screenshare { };
}