refactor
This commit is contained in:
parent
0c7440c81d
commit
819574d80f
125
flake.nix
125
flake.nix
@ -4,31 +4,44 @@
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
|
||||
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.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# https://github.com/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.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:
|
||||
#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/Mic92/sops-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://cyberchaos.dev/cyberchaoscreatures/musl-nixos/
|
||||
#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/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
|
||||
#nixpkgs-22.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
#nixpkgs-21.url = "github:NixOS/nixpkgs/nixos-21.11";
|
||||
#nixpkgs-20.url = "github:NixOS/nixpkgs/nixos-20.09";
|
||||
#nixpkgs-19.url = "github:NixOS/nixpkgs/nixos-19.09";
|
||||
#nixpkgs-19.flake = false; # Earlier versions are not flake-pure
|
||||
nixpkgs-22.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
nixpkgs-21.url = "github:NixOS/nixpkgs/nixos-21.11";
|
||||
nixpkgs-20.url = "github:NixOS/nixpkgs/nixos-20.09";
|
||||
nixpkgs-19.url = "github:NixOS/nixpkgs/nixos-19.09";
|
||||
nixpkgs-19.flake = false; # Earlier versions are not flake-pure
|
||||
/**/
|
||||
|
||||
# TODO: somehow make these private repos optional (a lazy fetch would be nice)
|
||||
pbsds-papers.url = "git+ssh://git@github.com/pbsds/papers.git";
|
||||
@ -54,6 +67,7 @@
|
||||
nixpkgs,
|
||||
unstable,
|
||||
nixos-hardware,
|
||||
nixos-generators,
|
||||
home-manager,
|
||||
...
|
||||
} @ inputs:
|
||||
@ -81,42 +95,55 @@
|
||||
#"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 {
|
||||
inherit system;
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
flakes = flake inputs system;
|
||||
};
|
||||
modules = modules ++ [ ./base.nix "${self}/hosts/${hostname}" ({
|
||||
imports = [
|
||||
# TODO: make work
|
||||
#inputs.flake-programs-sqlite.nixosModules.programs-sqlite
|
||||
];
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
flakes = flake inputs system;
|
||||
};
|
||||
# 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"
|
||||
];
|
||||
})];
|
||||
modules = [ (mkModule hostname domain system modules) ];
|
||||
};
|
||||
mkHosts = mk: with nixos-hardware.nixosModules; {
|
||||
# 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 ];
|
||||
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 ];
|
||||
sopp = mk "sopp" "pbsds.net" "x86_64-linux" [ 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 ];
|
||||
garp = mk "garp" "pbsds.net" "x86_64-linux" [ common-pc common-pc-ssd common-cpu-intel ]; # TODO: common-gpu-nvidia-nonprime ];
|
||||
#gomperud smattkuken skrytebiffen skalkesnerken balleby brumlebasse bingus skjrlaltatjlstad
|
||||
#bergjlot snortheimsmoen ditlefsen skrukkerud podebusk zmaragd makrell alfnes blix urke eple hasselknippe pytte uddu imdorf rosenqvist
|
||||
};
|
||||
in {
|
||||
inherit inputs;
|
||||
@ -134,18 +161,8 @@
|
||||
inherit flake forSystems;
|
||||
});
|
||||
|
||||
nixosConfigurations = let nm = nixos-hardware.nixosModules; in {
|
||||
# TODO: move nixos-hardware imports to the nixos configs?
|
||||
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
|
||||
};
|
||||
nixosModules = mkHosts mkModule;
|
||||
nixosConfigurations = mkHosts mkConfig;
|
||||
|
||||
homeConfigurations = forAllSystems ({ pkgs, flakes, ... }: let
|
||||
mkHome = user: home: modules: home-manager.lib.homeManagerConfiguration {
|
||||
@ -154,7 +171,9 @@
|
||||
home.username = user;
|
||||
home.homeDirectory = home;
|
||||
}];
|
||||
extraSpecialArgs.flakes = flakes;
|
||||
extraSpecialArgs = {
|
||||
inherit inputs flakes;
|
||||
};
|
||||
};
|
||||
in {
|
||||
pbsds = mkHome "pbsds" "/home/pbsds" [ ./users/pbsds/home ];
|
||||
|
@ -1,7 +1,10 @@
|
||||
{ config, pkgs, lib, inputs, ... }:
|
||||
{ config, pkgs, lib, inputs, flakes, ... }:
|
||||
{
|
||||
#imports = [ <home-manager/nixos> ];
|
||||
imports = [ inputs.home-manager.nixosModule ];
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit inputs flakes;
|
||||
};
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user