flake: make inputs configurable per nixos host
This commit is contained in:
parent
68ff2536e3
commit
d76fdbf81b
56
flake.nix
56
flake.nix
|
@ -3,11 +3,17 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
|
||||||
|
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; # gnome plugins broken
|
||||||
|
nixpkgs-2311.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||||
|
|
||||||
unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
# https://github.com/nix-community/home-manager
|
# https://github.com/nix-community/home-manager
|
||||||
home-manager.url = "github:nix-community/home-manager/release-23.05";
|
home-manager.url = "github:nix-community/home-manager/release-23.05";
|
||||||
|
#home-manager.url = "github:nix-community/home-manager/release-23.11";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
home-manager-2311.url = "github:nix-community/home-manager/release-23.11";
|
||||||
|
home-manager-2311.inputs.nixpkgs.follows = "nixpkgs-2311";
|
||||||
|
|
||||||
# https://github.com/NixOS/nixos-hardware
|
# https://github.com/NixOS/nixos-hardware
|
||||||
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
||||||
|
@ -23,6 +29,8 @@
|
||||||
# https://github.com/Mic92/sops-nix
|
# https://github.com/Mic92/sops-nix
|
||||||
sops-nix.url = "github:Mic92/sops-nix";
|
sops-nix.url = "github:Mic92/sops-nix";
|
||||||
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
|
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
sops-nix-2311.url = "github:Mic92/sops-nix";
|
||||||
|
sops-nix-2311.inputs.nixpkgs.follows = "nixpkgs-2311";
|
||||||
|
|
||||||
/** /
|
/** /
|
||||||
matrix-next.url = "github:dali99/nixos-matrix-modules"; # see https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/flake.nix
|
matrix-next.url = "github:dali99/nixos-matrix-modules"; # see https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/flake.nix
|
||||||
|
@ -62,17 +70,23 @@
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
#nixpkgs,
|
||||||
unstable,
|
#unstable,
|
||||||
nixos-hardware,
|
nixos-hardware,
|
||||||
nixos-generators,
|
nixos-generators,
|
||||||
home-manager,
|
#home-manager,
|
||||||
sops-nix,
|
sops-nix,
|
||||||
#flake-programs-sqlite,
|
#flake-programs-sqlite,
|
||||||
...
|
...
|
||||||
} @ inputs:
|
} @ inputs:
|
||||||
let
|
let
|
||||||
flake = inputs: system: nixpkgs.lib.mapAttrs (name: flake: {
|
inputs-2311 = inputs // {
|
||||||
|
nixpkgs = inputs.nixpkgs-2311;
|
||||||
|
home-manager = inputs.home-manager-2311;
|
||||||
|
sops-nix = inputs.sops-nix-2311;
|
||||||
|
};
|
||||||
|
|
||||||
|
flake = inputs: system: inputs.nixpkgs.lib.mapAttrs (name: flake: {
|
||||||
# TODO filter non-flake inputs
|
# TODO filter non-flake inputs
|
||||||
nixos = flake.nixosModules
|
nixos = flake.nixosModules
|
||||||
or null;
|
or null;
|
||||||
|
@ -83,10 +97,10 @@
|
||||||
or flake.lib
|
or flake.lib
|
||||||
or null;
|
or null;
|
||||||
}) inputs;
|
}) inputs;
|
||||||
forSystems = systems: f: nixpkgs.lib.genAttrs systems (system: f rec {
|
forSystems = systems: f: inputs.nixpkgs.lib.genAttrs systems (system: f rec {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||||
lib = nixpkgs.legacyPackages.${system}.lib;
|
lib = inputs.nixpkgs.legacyPackages.${system}.lib;
|
||||||
flakes = flake inputs system;
|
flakes = flake inputs system;
|
||||||
});
|
});
|
||||||
forAllSystems = forSystems [
|
forAllSystems = forSystems [
|
||||||
|
@ -95,7 +109,7 @@
|
||||||
#"riscv64-linux"
|
#"riscv64-linux"
|
||||||
];
|
];
|
||||||
|
|
||||||
mkModule = hostname: domain: system: modules: ({ lib, ... }: {
|
mkModule = hostname: domain: system: inputs: modules: ({ lib, ... }: {
|
||||||
#TODO: fix infinite recursion:
|
#TODO: fix infinite recursion:
|
||||||
/** /
|
/** /
|
||||||
_module.args = lib.mkFinal {
|
_module.args = lib.mkFinal {
|
||||||
|
@ -106,8 +120,8 @@
|
||||||
imports = [
|
imports = [
|
||||||
./base.nix
|
./base.nix
|
||||||
"${self}/hosts/${hostname}"
|
"${self}/hosts/${hostname}"
|
||||||
sops-nix.nixosModules.sops
|
inputs.sops-nix.nixosModules.sops
|
||||||
home-manager.nixosModule
|
inputs.home-manager.nixosModule
|
||||||
] ++ modules;
|
] ++ modules;
|
||||||
#++ flake-programs-sqlite.nixosModules.programs-sqlite; # TODO: make work
|
#++ flake-programs-sqlite.nixosModules.programs-sqlite; # TODO: make work
|
||||||
|
|
||||||
|
@ -135,7 +149,7 @@
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
#unstable = unstable.legacyPackages.${final.system};
|
#unstable = unstable.legacyPackages.${final.system};
|
||||||
unstable = import unstable { inherit system; config.allowUnfree = true; }; # TODO: inherit nixos config from stable
|
unstable = import inputs.unstable { inherit system; config.allowUnfree = true; }; # TODO: inherit nixos config from stable
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
# This makes commandline tools like 'nix run nixpkgs#hello'
|
# This makes commandline tools like 'nix run nixpkgs#hello'
|
||||||
|
@ -149,23 +163,23 @@
|
||||||
#"nixpkgs-unstable=github:NixOS/nixpkgs/nixos-unstable"
|
#"nixpkgs-unstable=github:NixOS/nixpkgs/nixos-unstable"
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
mkConfig = hostname: domain: system: modules: nixpkgs.lib.nixosSystem {
|
mkConfig = hostname: domain: system: inputs: modules: inputs.nixpkgs.lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
flakes = flake inputs system;
|
flakes = flake inputs system;
|
||||||
};
|
};
|
||||||
modules = [ (mkModule hostname domain system modules) ];
|
modules = [ (mkModule hostname domain system inputs modules) ];
|
||||||
};
|
};
|
||||||
mkHosts = mk: with nixos-hardware.nixosModules; {
|
mkHosts = mk: with nixos-hardware.nixosModules; {
|
||||||
# TODO: move nixos-hardware imports to the nixos configs?
|
# TODO: move nixos-hardware imports to the nixos configs?
|
||||||
noximilien = mk "noximilien" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel ];
|
noximilien = mk "noximilien" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-intel ];
|
||||||
brumlebasse = mk "brumlebasse" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-amd ];
|
brumlebasse = mk "brumlebasse" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-amd ];
|
||||||
nord = mk "nord" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-cpu-intel-sandy-bridge common-gpu-amd common-hidpi ];
|
nord = mk "nord" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-cpu-intel-sandy-bridge common-gpu-amd common-hidpi ];
|
||||||
sopp = mk "sopp" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ];
|
sopp = mk "sopp" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ];
|
||||||
bolle = mk "bolle" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel ];
|
bolle = mk "bolle" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-intel ];
|
||||||
eple = mk "eple" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel ];
|
eple = mk "eple" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-intel ];
|
||||||
garp = mk "garp" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel ]; # TODO: common-gpu-nvidia-nonprime ];
|
garp = mk "garp" "pbsds.net" "x86_64-linux" inputs [ common-pc common-pc-ssd common-cpu-intel ]; # TODO: common-gpu-nvidia-nonprime ];
|
||||||
#gomperud smattkuken skrytebiffen skalkesnerken balleby brumlebasse bingus skjrlaltatjlstad
|
#gomperud smattkuken skrytebiffen skalkesnerken balleby brumlebasse bingus skjrlaltatjlstad
|
||||||
#bergjlot snortheimsmoen ditlefsen skrukkerud podebusk zmaragd makrell alfnes blix urke eple hasselknippe pytte uddu imdorf rosenqvist
|
#bergjlot snortheimsmoen ditlefsen skrukkerud podebusk zmaragd makrell alfnes blix urke eple hasselknippe pytte uddu imdorf rosenqvist
|
||||||
};
|
};
|
||||||
|
@ -199,7 +213,7 @@
|
||||||
nixosConfigurations = mkHosts mkConfig;
|
nixosConfigurations = mkHosts mkConfig;
|
||||||
|
|
||||||
homeConfigurations = forAllSystems ({ pkgs, flakes, ... }: let
|
homeConfigurations = forAllSystems ({ pkgs, flakes, ... }: let
|
||||||
mkHome = user: home: modules: home-manager.lib.homeManagerConfiguration {
|
mkHome = user: home: modules: inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
modules = modules ++ [{
|
modules = modules ++ [{
|
||||||
home.username = user;
|
home.username = user;
|
||||||
|
|
Loading…
Reference in New Issue