2023-02-25 04:39:30 +01:00
|
|
|
{
|
2023-02-26 02:46:35 +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 11:14:01 +02:00
|
|
|
home-manager.url = "github:nix-community/home-manager/release-23.05";
|
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-06-29 02:43:56 +02:00
|
|
|
#https://github.com/considerate/nixos-odroidhc4
|
|
|
|
#https://cyberchaos.dev/cyberchaoscreatures/musl-nixos/
|
|
|
|
#https://github.com/numtide/system-manager
|
2023-07-02 09:19:35 +02:00
|
|
|
#nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions"
|
|
|
|
#https://github.com/numtide/nixpkgs-unfree # has a cache
|
2023-07-04 16:32:09 +02:00
|
|
|
#https://github.com/matthewbauer/nixiosk
|
|
|
|
#inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.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";
|
2023-06-20 02:01:04 +02:00
|
|
|
#nixpkgs-19.flake = false; # Earlier versions are not flake-pure
|
2023-06-18 05:10:08 +02:00
|
|
|
|
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-02-26 02:46:35 +01:00
|
|
|
|
2023-07-05 17:30:17 +02:00
|
|
|
nixConfig.extra-substituters = [
|
|
|
|
"https://cuda-maintainers.cachix.org"
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
"https://nixos-rocm.cachix.org"
|
|
|
|
"https://nixpkgs-unfree.cachix.org"
|
|
|
|
"https://numtide.cachix.org"
|
|
|
|
];
|
|
|
|
nixConfig.extra-trusted-public-keys = [
|
|
|
|
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
"nixos-rocm.cachix.org-1:VEpsf7pRIijjd8csKjFNBGzkBqOmw8H9PRmgAq14LnE="
|
|
|
|
"nixpkgs-unfree.cachix.org-1:hqvoInulhbV4nJ9yJOEr+4wxhDV4xq2d1DK7S6Nj6rs="
|
|
|
|
"numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE="
|
|
|
|
];
|
|
|
|
|
2023-03-04 00:09:57 +01:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
unstable,
|
|
|
|
nixos-hardware,
|
|
|
|
home-manager,
|
|
|
|
...
|
2023-03-01 03:20:31 +01:00
|
|
|
} @ inputs:
|
2023-02-25 04:39:30 +01:00
|
|
|
let
|
2023-07-03 01:34:00 +02:00
|
|
|
flake = inputs: system: nixpkgs.lib.mapAttrs (name: flake: {
|
2023-07-03 01:26:21 +02:00
|
|
|
# TODO filter non-flake inputs
|
2023-07-03 01:34:00 +02:00
|
|
|
nixos = flake.nixosModules
|
|
|
|
or null;
|
2023-07-03 01:26:21 +02:00
|
|
|
pkgs = flake.packages.${system}
|
|
|
|
or flake.legacyPackages.${system}
|
|
|
|
or null;
|
2023-07-03 01:34:00 +02:00
|
|
|
lib = flake.lib.${system}
|
|
|
|
or flake.lib
|
|
|
|
or null;
|
2023-07-03 01:26:21 +02:00
|
|
|
}) inputs;
|
2023-07-03 01:34:00 +02:00
|
|
|
forSystems = systems: f: nixpkgs.lib.genAttrs systems (system: f rec {
|
2023-06-20 01:36:49 +02:00
|
|
|
inherit system;
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
lib = nixpkgs.legacyPackages.${system}.lib;
|
2023-07-03 01:34:00 +02:00
|
|
|
flakes = flake inputs system;
|
2023-06-20 01:36:49 +02:00
|
|
|
});
|
2023-07-03 01:34:00 +02:00
|
|
|
forAllSystems = forSystems [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
#"riscv64-linux"
|
|
|
|
];
|
2023-03-09 07:03:15 +01:00
|
|
|
|
2023-06-24 20:23:38 +02:00
|
|
|
mkConfig = hostname: domain: system: modules: nixpkgs.lib.nixosSystem {
|
2023-02-25 04:39:30 +01:00
|
|
|
inherit system;
|
2023-06-20 01:39:19 +02:00
|
|
|
specialArgs = {
|
|
|
|
inherit inputs;
|
2023-07-03 01:34:00 +02:00
|
|
|
flakes = flake inputs system;
|
2023-06-20 01:39:19 +02:00
|
|
|
};
|
2023-08-08 19:42:51 +02:00
|
|
|
modules = modules ++ [ ./base.nix "${self}/hosts/${hostname}" ({
|
2023-06-20 01:39:19 +02:00
|
|
|
home-manager.extraSpecialArgs = {
|
|
|
|
inherit inputs;
|
2023-07-05 00:40:34 +02:00
|
|
|
flakes = flake inputs system;
|
2023-06-20 01:39:19 +02:00
|
|
|
};
|
2023-06-22 19:19:55 +02:00
|
|
|
# still needed even if using networkd
|
2023-02-26 02:46:35 +01:00
|
|
|
networking.hostName = hostname;
|
2023-06-20 01:39:35 +02:00
|
|
|
networking.domain = domain;
|
|
|
|
networking.search = [ domain ];
|
2023-07-03 02:23:35 +02:00
|
|
|
nixpkgs.overlays = [
|
2023-02-26 02:46:35 +01:00
|
|
|
(final: prev: {
|
2023-07-03 02:23:35 +02:00
|
|
|
#unstable = unstable.legacyPackages.${final.system};
|
|
|
|
unstable = import unstable { inherit system; config.allowUnfree = true; }; # TODO: inherit nixos config from stable
|
2023-02-26 02:46:35 +01:00
|
|
|
})
|
|
|
|
];
|
2023-02-25 04:39:30 +01:00
|
|
|
# This makes commandline tools like 'nix run nixpkgs#hello'
|
2023-02-26 02:46:35 +01:00
|
|
|
# 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;
|
2023-07-05 00:40:34 +02:00
|
|
|
nix.registry.nixpkgs-unstable.flake = inputs.unstable;
|
|
|
|
#nix.registry.nixpkgs-unstable.flake.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2023-02-25 04:39:30 +01:00
|
|
|
nix.nixPath = [
|
|
|
|
"nixpkgs=${inputs.nixpkgs}"
|
2023-07-05 00:40:34 +02:00
|
|
|
"nixpkgs-unstable=${inputs.unstable}"
|
|
|
|
#"nixpkgs-unstable=github:NixOS/nixpkgs/nixos-unstable"
|
2023-02-25 04:39:30 +01:00
|
|
|
];
|
|
|
|
})];
|
|
|
|
};
|
|
|
|
in {
|
2023-03-03 21:42:29 +01:00
|
|
|
inherit inputs;
|
2023-03-09 07:03:15 +01:00
|
|
|
|
2023-07-03 02:23:35 +02:00
|
|
|
packages = forAllSystems ({ pkgs, flakes, ... }: {
|
2023-07-03 01:35:05 +02:00
|
|
|
mpv-webm = pkgs.callPackage ./pkgs/mpv-webm.nix {}; # TODO: https://github.com/NixOS/nixpkgs/pull/238659
|
|
|
|
nixos-rebuild-nom = with pkgs; writeScriptBin "nixos-rebuild" ''
|
|
|
|
exec ${nixos-rebuild}/bin/nixos-rebuild "$@" |& ${nix-output-monitor}/bin/nom
|
|
|
|
'';
|
2023-03-19 04:23:38 +01:00
|
|
|
});
|
2023-03-09 07:03:15 +01:00
|
|
|
|
2023-07-03 01:34:00 +02:00
|
|
|
lib = {
|
|
|
|
inherit flake forSystems;
|
2023-07-03 02:23:35 +02:00
|
|
|
} // forAllSystems ({ ... }: {
|
2023-07-03 01:34:00 +02:00
|
|
|
inherit flake forSystems;
|
|
|
|
});
|
|
|
|
|
2023-03-19 04:23:38 +01:00
|
|
|
nixosConfigurations = let nm = nixos-hardware.nixosModules; in {
|
|
|
|
# TODO: move nixos-hardware imports to the nixos configs?
|
2023-06-20 01:39:35 +02:00
|
|
|
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 ]);
|
2023-06-24 19:11:49 +02:00
|
|
|
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 ]);
|
2023-09-07 01:44:45 +02:00
|
|
|
sopp = mkConfig "sopp" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia-nonprime ]);
|
2023-09-05 22:15:40 +02:00
|
|
|
garp = mkConfig "garp" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel common-gpu-nvidia ]);
|
|
|
|
#gomperud smattkuken skrytebiffen skalkesnerken
|
2023-03-19 04:23:38 +01:00
|
|
|
};
|
2023-03-09 07:03:15 +01:00
|
|
|
|
2023-07-05 00:40:34 +02:00
|
|
|
homeConfigurations = forAllSystems ({ pkgs, flakes, ... }: let
|
2023-06-20 01:39:35 +02:00
|
|
|
mkHome = user: home: modules: home-manager.lib.homeManagerConfiguration {
|
|
|
|
inherit pkgs;
|
|
|
|
modules = modules ++ [{
|
|
|
|
home.username = user;
|
|
|
|
home.homeDirectory = home;
|
|
|
|
}];
|
2023-07-05 00:40:34 +02:00
|
|
|
extraSpecialArgs.flakes = flakes;
|
2023-03-09 09:31:53 +01:00
|
|
|
};
|
2023-03-19 04:23:38 +01:00
|
|
|
in {
|
2023-06-20 01:39:35 +02:00
|
|
|
pbsds = mkHome "pbsds" "/home/pbsds" [ ./users/pbsds/home ];
|
|
|
|
pbsds-gnome = mkHome "pbsds" "/home/pbsds" [ ./users/pbsds/home/gnome.nix ];
|
2023-02-25 04:39:30 +01:00
|
|
|
});
|
2023-03-09 07:03:15 +01:00
|
|
|
|
2023-07-03 01:26:21 +02:00
|
|
|
devShells = forAllSystems ({ pkgs, flakes, ... }: let
|
2023-07-05 17:30:17 +02:00
|
|
|
mkShell = packages: pkgs.mkShellNoCC { inherit packages; };
|
2023-06-24 19:11:49 +02:00
|
|
|
envrc-pkgs = [
|
2023-07-03 01:35:05 +02:00
|
|
|
flakes.self.pkgs.nixos-rebuild-nom
|
2023-07-03 01:26:21 +02:00
|
|
|
pkgs.home-manager
|
|
|
|
pkgs.nix-output-monitor
|
|
|
|
pkgs.cachix
|
2023-03-19 04:23:38 +01:00
|
|
|
];
|
2023-06-24 19:11:49 +02:00
|
|
|
in {
|
|
|
|
envrc-local = mkShell envrc-pkgs;
|
2023-07-03 02:23:35 +02:00
|
|
|
envrc-remote = mkShell (envrc-pkgs ++ [
|
|
|
|
flakes.unstable.pkgs.remote-exec # TODO: stable
|
2023-07-03 01:26:21 +02:00
|
|
|
pkgs.yq
|
|
|
|
pkgs.rsync
|
2023-06-24 19:11:49 +02:00
|
|
|
]);
|
|
|
|
remoteenv = mkShell [
|
2023-07-03 01:35:05 +02:00
|
|
|
flakes.self.pkgs.nixos-rebuild-nom
|
2023-03-19 04:23:38 +01:00
|
|
|
];
|
2023-02-26 21:28:44 +01:00
|
|
|
});
|
2023-03-09 07:03:15 +01:00
|
|
|
|
2023-02-25 04:39:30 +01:00
|
|
|
};
|
|
|
|
}
|