mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
who let him cook
This commit is contained in:
parent
07b33bd9c8
commit
afe576fe00
2 changed files with 56 additions and 56 deletions
|
|
@ -10,9 +10,9 @@ in
|
||||||
# Only good use case for rec
|
# Only good use case for rec
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
needsSystem =
|
wrench = lib.flip lib.pipe;
|
||||||
output:
|
|
||||||
builtins.elem output [
|
needsSystem = lib.flip builtins.elem [
|
||||||
"defaultPackage"
|
"defaultPackage"
|
||||||
"devShell"
|
"devShell"
|
||||||
"devShells"
|
"devShells"
|
||||||
|
|
@ -22,59 +22,61 @@ rec {
|
||||||
];
|
];
|
||||||
|
|
||||||
constructInputs' =
|
constructInputs' =
|
||||||
system: inputs:
|
system:
|
||||||
lib.pipe inputs [
|
wrench [
|
||||||
(lib.filterAttrs (_: lib.isType "flake"))
|
(lib.filterAttrs (_: lib.isType "flake"))
|
||||||
(lib.mapAttrs (_: lib.mapAttrs (name: value: if needsSystem name then value.${system} else value)))
|
(lib.mapAttrs (_: lib.mapAttrs (name: value: if needsSystem name then value.${system} else value)))
|
||||||
];
|
];
|
||||||
|
|
||||||
listNixFilesRecursive =
|
listNixFilesRecursive = wrench [
|
||||||
path:
|
builtins.unsafeDiscardStringContext
|
||||||
builtins.filter (lib.hasSuffix ".nix") (map toString (lib.filesystem.listFilesRecursive path));
|
lib.filesystem.listFilesRecursive
|
||||||
|
(builtins.filter (lib.hasSuffix ".nix"))
|
||||||
listNixFilesRecursiveDiscardStringContext =
|
];
|
||||||
x: listNixFilesRecursive (builtins.unsafeDiscardStringContext x);
|
|
||||||
|
|
||||||
fixModuleSystem =
|
fixModuleSystem =
|
||||||
file:
|
file:
|
||||||
lib.pipe file [
|
lib.pipe file [
|
||||||
builtins.readFile
|
builtins.readFile
|
||||||
(builtins.replaceStrings (lib.singleton "#_file") (lib.singleton ''_file = "${file}";''))
|
(builtins.replaceStrings [ "#_file" ] [ "_file = \"${file}\";" ])
|
||||||
(builtins.toFile (builtins.baseNameOf file))
|
(builtins.toFile (builtins.baseNameOf file))
|
||||||
];
|
];
|
||||||
|
|
||||||
mkModules =
|
mkModules =
|
||||||
path:
|
path:
|
||||||
lib.listToAttrs (
|
lib.pipe path [
|
||||||
map (name: {
|
listNixFilesRecursive
|
||||||
|
(map (name: {
|
||||||
name = lib.pipe name [
|
name = lib.pipe name [
|
||||||
(lib.removeSuffix ".nix")
|
(lib.removeSuffix ".nix")
|
||||||
(lib.removePrefix "${path}/")
|
(lib.removePrefix "${path}/")
|
||||||
];
|
];
|
||||||
value = fixModuleSystem name;
|
value = fixModuleSystem name;
|
||||||
}) (listNixFilesRecursiveDiscardStringContext path)
|
}))
|
||||||
);
|
builtins.listToAttrs
|
||||||
|
];
|
||||||
|
|
||||||
gerg-utils =
|
gerg-utils =
|
||||||
config: outputs:
|
pkgsf: outputs:
|
||||||
lib.foldAttrs lib.mergeAttrs { } (
|
lib.pipe
|
||||||
map (
|
[
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
(map (
|
||||||
system:
|
system:
|
||||||
let
|
builtins.mapAttrs (
|
||||||
pkgs =
|
name: value: if needsSystem name then { ${system} = value (pkgsf system); } else value
|
||||||
if config == { } then
|
) outputs
|
||||||
unstable.legacyPackages.${system}
|
))
|
||||||
else
|
(lib.foldAttrs lib.mergeAttrs { })
|
||||||
import unstable { inherit system config; };
|
];
|
||||||
in
|
|
||||||
lib.mapAttrs (name: value: if needsSystem name then { ${system} = value pkgs; } else value) outputs
|
|
||||||
) [ "x86_64-linux" ]
|
|
||||||
);
|
|
||||||
|
|
||||||
mkHosts =
|
mkHosts =
|
||||||
system: names:
|
system:
|
||||||
lib.genAttrs names (
|
lib.flip lib.genAttrs (
|
||||||
name:
|
hostName:
|
||||||
# Whats lib.nixosSystem? never heard of her
|
# Whats lib.nixosSystem? never heard of her
|
||||||
lib.evalModules {
|
lib.evalModules {
|
||||||
specialArgs.modulesPath = "${unstable}/nixos/modules";
|
specialArgs.modulesPath = "${unstable}/nixos/modules";
|
||||||
|
|
@ -85,28 +87,26 @@ rec {
|
||||||
in
|
in
|
||||||
builtins.concatLists [
|
builtins.concatLists [
|
||||||
(importWithInputs' (builtins.attrValues self.nixosModules))
|
(importWithInputs' (builtins.attrValues self.nixosModules))
|
||||||
(importWithInputs' (
|
(importWithInputs' (map fixModuleSystem (listNixFilesRecursive "${self}/hosts/${hostName}")))
|
||||||
map fixModuleSystem (listNixFilesRecursiveDiscardStringContext "${self}/hosts/${name}")
|
|
||||||
))
|
|
||||||
(import "${unstable}/nixos/modules/module-list.nix")
|
(import "${unstable}/nixos/modules/module-list.nix")
|
||||||
(lib.singleton {
|
(lib.singleton {
|
||||||
networking.hostName = name;
|
networking = {
|
||||||
|
inherit hostName;
|
||||||
|
};
|
||||||
nixpkgs.hostPlatform = system;
|
nixpkgs.hostPlatform = system;
|
||||||
})
|
})
|
||||||
(lib.optionals (self.diskoConfigurations ? "disko-${name}") [
|
(lib.optionals (self.diskoConfigurations ? "disko-${hostName}") [
|
||||||
self.diskoConfigurations."disko-${name}"
|
self.diskoConfigurations."disko-${hostName}"
|
||||||
disko.nixosModules.default
|
disko.nixosModules.default
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
mkDisko =
|
mkDisko = lib.listToAttrs (
|
||||||
names:
|
|
||||||
lib.listToAttrs (
|
|
||||||
map (name: {
|
map (name: {
|
||||||
name = "disko-${name}";
|
name = "disko-${name}";
|
||||||
value.disko.devices = import "${self}/disko/${name}.nix" lib;
|
value.disko.devices = import "${self}/disko/${name}.nix" lib;
|
||||||
}) names
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
inputs@{ self, ... }:
|
inputs@{ self, unstable, ... }:
|
||||||
let
|
let
|
||||||
lib = import ./lib inputs;
|
lib = import ./lib inputs;
|
||||||
in
|
in
|
||||||
lib.gerg-utils { } {
|
lib.gerg-utils (s: unstable.legacyPackages.${s}) {
|
||||||
inherit lib;
|
inherit lib;
|
||||||
nixosConfigurations = lib.mkHosts "x86_64-linux" [
|
nixosConfigurations = lib.mkHosts "x86_64-linux" [
|
||||||
"gerg-desktop"
|
"gerg-desktop"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue