This commit is contained in:
Peder Bergebakken Sundt 2023-10-14 18:30:34 +02:00
parent 0c7440c81d
commit 819574d80f
2 changed files with 76 additions and 54 deletions

125
flake.nix
View File

@ -4,31 +4,44 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
# 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.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
# https://github.com/NixOS/nixos-hardware
nixos-hardware.url = "github:NixOS/nixos-hardware"; nixos-hardware.url = "github:NixOS/nixos-hardware";
# https://github.com/wamserma/flake-programs-sqlite
flake-programs-sqlite.url = "github:wamserma/flake-programs-sqlite"; flake-programs-sqlite.url = "github:wamserma/flake-programs-sqlite";
flake-programs-sqlite.inputs.nixpkgs.follows = "nixpkgs"; flake-programs-sqlite.inputs.nixpkgs.follows = "nixpkgs";
# https://github.com/nix-community/nixos-generators
nixos-generators.url = "github:nix-community/nixos-generators";
nixos-generators.inputs.nixpkgs.follows = "nixpkgs";
#TODO: #TODO:
#sops-nix.url = "github:Mic92/sops-nix"; /** /
#sops-nix.inputs.nixpkgs.follows = "nixpkgs"; # https://github.com/Mic92/sops-nix
#matrix-next.url = "github:dali99/nixos-matrix-modules"; # see https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/flake.nix sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
matrix-next.url = "github:dali99/nixos-matrix-modules"; # see https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/flake.nix
#https://github.com/considerate/nixos-odroidhc4 #https://github.com/considerate/nixos-odroidhc4
#https://cyberchaos.dev/cyberchaoscreatures/musl-nixos/ #https://cyberchaos.dev/cyberchaoscreatures/musl-nixos/
#https://github.com/numtide/system-manager #https://github.com/numtide/system-manager
#nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions" nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions"
#https://github.com/numtide/nixpkgs-unfree # has a cache #https://github.com/numtide/nixpkgs-unfree # has a cache
#https://github.com/matthewbauer/nixiosk #https://github.com/matthewbauer/nixiosk
#inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
# used to host old docs # used to host old docs
#nixpkgs-22.url = "github:NixOS/nixpkgs/nixos-22.11"; nixpkgs-22.url = "github:NixOS/nixpkgs/nixos-22.11";
#nixpkgs-21.url = "github:NixOS/nixpkgs/nixos-21.11"; nixpkgs-21.url = "github:NixOS/nixpkgs/nixos-21.11";
#nixpkgs-20.url = "github:NixOS/nixpkgs/nixos-20.09"; nixpkgs-20.url = "github:NixOS/nixpkgs/nixos-20.09";
#nixpkgs-19.url = "github:NixOS/nixpkgs/nixos-19.09"; nixpkgs-19.url = "github:NixOS/nixpkgs/nixos-19.09";
#nixpkgs-19.flake = false; # Earlier versions are not flake-pure nixpkgs-19.flake = false; # Earlier versions are not flake-pure
/**/
# TODO: somehow make these private repos optional (a lazy fetch would be nice) # TODO: somehow make these private repos optional (a lazy fetch would be nice)
pbsds-papers.url = "git+ssh://git@github.com/pbsds/papers.git"; pbsds-papers.url = "git+ssh://git@github.com/pbsds/papers.git";
@ -54,6 +67,7 @@
nixpkgs, nixpkgs,
unstable, unstable,
nixos-hardware, nixos-hardware,
nixos-generators,
home-manager, home-manager,
... ...
} @ inputs: } @ inputs:
@ -81,42 +95,55 @@
#"riscv64-linux" #"riscv64-linux"
]; ];
mkModule = hostname: domain: system: modules: ({ lib, ... }: {
#TODO: fix infinite recursion:
/** /
_module.args = lib.mkFinal {
inherit inputs;
flakes = flake inputs system;
};
/**/
imports = [ ./base.nix "${self}/hosts/${hostname}"] ++ modules;
#++ inputs.flake-programs-sqlite.nixosModules.programs-sqlite; # TODO: make work
# still needed even if using networkd
networking.hostName = hostname;
networking.domain = domain;
networking.search = [ domain ];
nixpkgs.overlays = [
(final: prev: {
#unstable = unstable.legacyPackages.${final.system};
unstable = import unstable { inherit system; config.allowUnfree = true; }; # TODO: inherit nixos config from stable
})
];
# This makes commandline tools like 'nix run nixpkgs#hello'
# and 'nix-shell -p hello' use the same channel as system was built with
nix.registry.nixpkgs.flake = inputs.nixpkgs;
nix.registry.nixpkgs-unstable.flake = inputs.unstable;
#nix.registry.nixpkgs-unstable.flake.url = "github:NixOS/nixpkgs/nixos-unstable";
nix.nixPath = [
"nixpkgs=${inputs.nixpkgs}"
"nixpkgs-unstable=${inputs.unstable}"
#"nixpkgs-unstable=github:NixOS/nixpkgs/nixos-unstable"
];
});
mkConfig = hostname: domain: system: modules: nixpkgs.lib.nixosSystem { mkConfig = hostname: domain: system: modules: nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
flakes = flake inputs system; flakes = flake inputs system;
}; };
modules = modules ++ [ ./base.nix "${self}/hosts/${hostname}" ({ modules = [ (mkModule hostname domain system modules) ];
imports = [ };
# TODO: make work mkHosts = mk: with nixos-hardware.nixosModules; {
#inputs.flake-programs-sqlite.nixosModules.programs-sqlite # 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 ];
home-manager.extraSpecialArgs = { 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 ];
inherit inputs; sopp = mk "sopp" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ];
flakes = flake inputs system; bolle = mk "bolle" "pbsds.net" "x86_64-linux" [ 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 ];
# still needed even if using networkd #gomperud smattkuken skrytebiffen skalkesnerken balleby brumlebasse bingus skjrlaltatjlstad
networking.hostName = hostname; #bergjlot snortheimsmoen ditlefsen skrukkerud podebusk zmaragd makrell alfnes blix urke eple hasselknippe pytte uddu imdorf rosenqvist
networking.domain = domain;
networking.search = [ domain ];
nixpkgs.overlays = [
(final: prev: {
#unstable = unstable.legacyPackages.${final.system};
unstable = import unstable { inherit system; config.allowUnfree = true; }; # TODO: inherit nixos config from stable
})
];
# This makes commandline tools like 'nix run nixpkgs#hello'
# and 'nix-shell -p hello' use the same channel as system was built with
nix.registry.nixpkgs.flake = inputs.nixpkgs;
nix.registry.nixpkgs-unstable.flake = inputs.unstable;
#nix.registry.nixpkgs-unstable.flake.url = "github:NixOS/nixpkgs/nixos-unstable";
nix.nixPath = [
"nixpkgs=${inputs.nixpkgs}"
"nixpkgs-unstable=${inputs.unstable}"
#"nixpkgs-unstable=github:NixOS/nixpkgs/nixos-unstable"
];
})];
}; };
in { in {
inherit inputs; inherit inputs;
@ -134,18 +161,8 @@
inherit flake forSystems; inherit flake forSystems;
}); });
nixosConfigurations = let nm = nixos-hardware.nixosModules; in { nixosModules = mkHosts mkModule;
# TODO: move nixos-hardware imports to the nixos configs? nixosConfigurations = mkHosts mkConfig;
noximilien = mkConfig "noximilien" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
bolle = mkConfig "bolle" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
nord = mkConfig "nord" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-cpu-intel-sandy-bridge common-gpu-amd common-hidpi ]);
sopp = mkConfig "sopp" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ]);
#garp = mkConfig "garp" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ]);
#garp = mkConfig "garp" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia ]);
garp = mkConfig "garp" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
#gomperud smattkuken skrytebiffen skalkesnerken balleby brumlebasse bingus skjrlaltatjlstad
#Bergjlot Snortheimsmoen Ditlefsen Skrukkerud Podebusk Zmaragd Makrell Alfnes Blix Urke Eple Hasselknippe Pytte Uddu Imdorf Rosenqvist
};
homeConfigurations = forAllSystems ({ pkgs, flakes, ... }: let homeConfigurations = forAllSystems ({ pkgs, flakes, ... }: let
mkHome = user: home: modules: home-manager.lib.homeManagerConfiguration { mkHome = user: home: modules: home-manager.lib.homeManagerConfiguration {
@ -154,7 +171,9 @@
home.username = user; home.username = user;
home.homeDirectory = home; home.homeDirectory = home;
}]; }];
extraSpecialArgs.flakes = flakes; extraSpecialArgs = {
inherit inputs flakes;
};
}; };
in { in {
pbsds = mkHome "pbsds" "/home/pbsds" [ ./users/pbsds/home ]; pbsds = mkHome "pbsds" "/home/pbsds" [ ./users/pbsds/home ];

View File

@ -1,7 +1,10 @@
{ config, pkgs, lib, inputs, ... }: { config, pkgs, lib, inputs, flakes, ... }:
{ {
#imports = [ <home-manager/nixos> ]; #imports = [ <home-manager/nixos> ];
imports = [ inputs.home-manager.nixosModule ]; imports = [ inputs.home-manager.nixosModule ];
home-manager.extraSpecialArgs = {
inherit inputs flakes;
};
home-manager.useGlobalPkgs = true; # go brrr, reuse overrides home-manager.useGlobalPkgs = true; # go brrr, reuse overrides
#home-manager.useUserPackages = true # needed if VM, somewhat brrr, installs user packages to /etc instead of ~/.nix-profile #home-manager.useUserPackages = true # needed if VM, somewhat brrr, installs user packages to /etc instead of ~/.nix-profile