config/flake.nix

144 lines
5.6 KiB
Nix
Raw Normal View History

2023-02-25 04:39:30 +01:00
{
description = "pbsds' system/home flake";
2023-02-25 04:39:30 +01:00
2023-03-19 04:23:38 +01:00
inputs = {
2023-06-11 11:14:01 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
2023-03-19 04:23:38 +01:00
unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
2023-06-11 10:12:42 +02:00
#nur.url = "github:nix-community/NUR";
2023-06-11 11:14:01 +02:00
home-manager.url = "github:nix-community/home-manager/release-23.05";
2023-06-11 10:12:42 +02:00
#home-manager.url = "github:nix-community/home-manager";
2023-03-19 04:23:38 +01:00
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware";
2023-02-25 04:39:30 +01:00
2023-03-19 04:23:38 +01:00
#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
2023-02-25 04:39:30 +01:00
2023-06-18 05:10:08 +02:00
# 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 pure
2023-03-19 04:23:38 +01:00
# TODO: somehow make these private repos optional (a lazy fetch would be nice)
pbsds-papers.url = "git+ssh://git@github.com/pbsds/papers.git";
2023-03-09 21:13:18 +01:00
2023-03-19 04:23:38 +01:00
# temporary stuff i want to use
2023-06-11 11:24:24 +02:00
# TODO: can i fetch a subset of files of these?
2023-03-19 04:23:38 +01:00
pr-polaris14.url = "github:pbsds/nixpkgs/polaris-14";
pr-remote-exec.url = "github:pbsds/nixpkgs/remote-exec-init";
};
2023-03-04 00:09:57 +01:00
outputs = {
self,
nixpkgs,
unstable,
nixos-hardware,
nur,
home-manager,
...
2023-03-01 03:20:31 +01:00
} @ inputs:
2023-02-25 04:39:30 +01:00
let
2023-03-09 07:03:15 +01:00
nixlib = nixpkgs.lib;
2023-02-25 04:39:30 +01:00
systems = [
"x86_64-linux"
"aarch64-linux"
#"riscv64-linux"
];
2023-03-19 04:23:38 +01:00
forAllSystems = f: nixlib.genAttrs systems (system: f system);
2023-03-09 07:03:15 +01:00
overlays = nixlib.mapAttrsToList (name: val: val) self.overlays;
2023-03-09 09:28:11 +01:00
# TODO: move unstable and nur here?
tmpConfig = {
2023-02-25 04:39:30 +01:00
disabledModules = [ "services/misc/polaris.nix" ];
imports = [ "${inputs.pr-polaris14}/nixos/modules/services/misc/polaris.nix" ];
nixpkgs.overlays = [(final: prev: { # TODO: nixpkgs.config.packageOverrides ?
polaris = prev.callPackage "${inputs.pr-polaris14}/pkgs/servers/polaris" { };
polaris-web = prev.callPackage "${inputs.pr-polaris14}/pkgs/servers/polaris/web.nix" { };
2023-06-18 05:10:08 +02:00
remote-exec = prev.python3Packages.callPackage "${inputs.pr-remote-exec}/pkgs/tools/misc/remote-exec" { };
2023-02-25 04:39:30 +01:00
})];
};
2023-03-19 04:23:38 +01:00
mkConfig = hostname: system: modules: nixlib.nixosSystem {
2023-02-25 04:39:30 +01:00
inherit system;
specialArgs = { inherit inputs; };
modules = modules ++ [ ./base.nix "${self}/hosts/${hostname}" tmpConfig ({
networking.hostName = hostname;
networking.domain = "pbsds.net";
networking.search = [ "pbsds.net" ];
nixpkgs.overlays = [ # TODO: consider nixpkgs.config.packageOverrides
#(final: prev: self.packages.${system})
(final: prev: {
unstable = unstable.legacyPackages.${final.system};
#unstable = import unstable { inherit system; };
2023-06-11 10:12:42 +02:00
#nur = import nur { inherit (prev) pkgs; nurpkgs = prev.pkgs; };
##nur = import nur { inherit (prev) pkgs; nurpkgs = import nixpkgs { inherit final.system: }; }; # TODO: nurpkgs?
})
];
2023-02-25 04:39:30 +01:00
# This makes commandline tools like 'nix run nixpkgs#hello'
# and 'nix-shell -p hello' use the same channel as system was built with
2023-02-25 04:39:30 +01:00
nix.registry.nixpkgs.flake = inputs.nixpkgs;
nix.registry.unstable.flake = inputs.unstable;
nix.nixPath = [
"nixpkgs=${inputs.nixpkgs}"
"unstable=${inputs.unstable}" # TODO: needed?
2023-02-25 04:39:30 +01:00
];
})];
};
in {
2023-03-09 07:03:15 +01:00
2023-03-03 21:42:29 +01:00
inherit inputs;
2023-03-09 07:03:15 +01:00
overlays.remote-exec = (final: prev: {
2023-06-18 05:10:08 +02:00
remote-exec = prev.python3Packages.callPackage "${inputs.pr-remote-exec}/pkgs/tools/misc/remote-exec" {};
2023-03-09 07:03:15 +01:00
});
packages = forAllSystems(system:
2023-03-19 04:23:38 +01:00
let pkgs = nixpkgs.legacyPackages.${system}; in {
inherit (self.overlays.remote-exec null pkgs) remote-exec;
});
2023-03-09 07:03:15 +01:00
2023-03-19 04:23:38 +01:00
nixosConfigurations = let nm = nixos-hardware.nixosModules; in {
# TODO: move nixos-hardware imports to the nixos configs?
noximilien = mkConfig "noximilien" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
bolle = mkConfig "bolle" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
nord = mkConfig "nord" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-gpu-amd ]);
2023-06-19 04:02:48 +02:00
sopp = mkConfig "sopp" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ]);
2023-03-19 04:23:38 +01:00
};
2023-03-09 07:03:15 +01:00
2023-03-19 04:23:38 +01:00
homeConfigurations = forAllSystems (system: let
mkHome = modules: home-manager.lib.homeManagerConfiguration {
2023-02-25 04:39:30 +01:00
pkgs = nixpkgs.legacyPackages.${system};
2023-03-19 04:23:38 +01:00
inherit modules;
2023-03-09 09:31:53 +01:00
};
2023-03-19 04:23:38 +01:00
in {
pbsds = mkHome [ ./users/pbsds/home ];
pbsds-gnome = mkHome [ ./users/pbsds/home/gnome.nix ];
2023-02-25 04:39:30 +01:00
});
2023-03-09 07:03:15 +01:00
2023-03-19 04:23:38 +01:00
devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
remote-exec = pkgs.remote-exec or (self.overlays.remote-exec pkgs pkgs).remote-exec;
nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" ''
exec ${pkgs.nixos-rebuild}/bin/nixos-rebuild "$@" |& ${pkgs.nix-output-monitor}/bin/nom
'';
mkShell = packages: pkgs.mkShell { inherit packages; };
in {
2023-06-11 11:24:24 +02:00
remoteenv = mkShell [
2023-03-19 04:23:38 +01:00
nixos-rebuild-nom
];
2023-06-11 11:24:24 +02:00
envrc = mkShell [
2023-03-19 04:23:38 +01:00
nixos-rebuild-nom
pkgs.home-manager
pkgs.nix-output-monitor
];
2023-06-18 05:10:08 +02:00
envrc-remote = mkShell [
2023-03-19 04:23:38 +01:00
remote-exec
pkgs.yq
];
2023-02-26 21:28:44 +01:00
});
2023-03-09 07:03:15 +01:00
2023-02-25 04:39:30 +01:00
};
}