nixos-configuration/outputs.nix

80 lines
2.8 KiB
Nix
Raw Normal View History

2024-07-07 08:34:47 +02:00
{
inputs ? import ./inputs.nix {},
selfPath ? ./.
}:
2024-06-17 07:54:59 +02:00
let
lib = (import "${inputs.nixpkgs}/lib").extend (import ./lib/overlays/version-info-fixup.nix { revision = inputs.lock.nixpkgs.revision; });
2024-06-17 07:54:59 +02:00
2025-02-09 08:53:27 +01:00
systems = [
"x86_64-linux"
"aarch64-linux"
];
# (system -> x) -> { [system] := x }
forEachSystem = x: lib.pipe systems [
(builtins.map (system: { name = system; value = x system; }))
builtins.listToAttrs
];
2024-06-17 07:54:59 +02:00
self = {
2024-07-07 08:16:17 +02:00
inherit inputs lib self;
outPath = selfPath;
2024-06-17 07:54:59 +02:00
modifiedNixpkgs = import ./pkgs/top-level/impure.nix;
modifiedNixpkgsPure = import ./pkgs/top-level/default.nix;
2025-02-09 08:53:27 +01:00
packagesForSystem = system: self.modifiedNixpkgsPure { localSystem = system; };
packages = forEachSystem (system: let
nixpkgs = import "${inputs.nixpkgs}/pkgs/top-level/default.nix" { localSystem = system; };
attrnames = builtins.attrNames nixpkgs;
in
builtins.removeAttrs (self.pkgsForSystem system) attrnames
);
2024-06-17 07:54:59 +02:00
overlays = {
2024-10-02 18:38:26 +02:00
cosmicPackages = import ./pkgs/overlays/cosmic-packages.nix { inherit inputs; };
2024-06-17 07:54:59 +02:00
selfExpr = import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = inputs.nixpkgs; };
2025-01-12 21:54:47 +01:00
unstableWithMeta = import ./pkgs/overlays/unstable-with-meta.nix { unstableSource = inputs.nixpkgs-unstable; revision = inputs.lock.nixpkgs-unstable.revision; };
2024-06-17 07:54:59 +02:00
versionInfoFixup = import ./pkgs/overlays/version-info-fixup.nix { inherit inputs; };
};
nixosConfigurations = let
nixosSystem = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix";
mkNixosSystem = path: nixosSystem {
inherit lib;
modules = [
path
{
config.nixpkgs.overlays = [
( import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = "${self}/pkgs/top-level/impure.nix"; } )
( import ./pkgs/top-level/by-name-overlay.nix "${self}/pkgs/by-name" )
self.overlays.versionInfoFixup
];
}
];
specialArgs = { inherit self inputs; };
};
in
2025-02-09 03:23:43 +01:00
# mapped attrset of nix file paths to attrSet with initialized NixOS configurations,
# whose names are derived from file names
lib.pipe ./hosts [
builtins.readDir
# filter out files that are not .nix files, directories with default.nix or starting with . (dot, hidden files)
( lib.filterAttrs (name: type:
(
(type == "regular" && lib.hasSuffix ".nix" name)
|| (type == "directory" && builtins.pathExists "${./.}/hosts/${name}/default.nix")
)
&& !lib.hasPrefix "." name
))
(builtins.mapAttrs (name: type: {
# remove .nix extension
name = if type == "directory" then name else builtins.substring 0 (builtins.stringLength name - 4) name;
# initialize NixOS configuration
value = mkNixosSystem ./hosts/${name};
}))
builtins.attrValues
builtins.listToAttrs
];
2024-06-17 07:54:59 +02:00
};
in self