flake.nix: Clean up and refactor

This commit is contained in:
Tristan Daniël Maat 2022-10-12 01:17:49 +01:00
parent 7095ab2631
commit e512e73b5e
Signed by: tlater
GPG key ID: 49670FD774E43268
2 changed files with 107 additions and 114 deletions

View file

@ -2,11 +2,26 @@
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1649676176, "lastModified": 1659877975,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -70,7 +85,6 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
@ -125,9 +139,7 @@
}, },
"tlaternet-templates": { "tlaternet-templates": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": "flake-utils",
"flake-utils"
],
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
@ -148,9 +160,7 @@
}, },
"tlaternet-webserver": { "tlaternet-webserver": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": "flake-utils_2",
"flake-utils"
],
"naersk": "naersk", "naersk": "naersk",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"

View file

@ -4,7 +4,6 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11"; nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
nixos-hardware.url = "github:nixos/nixos-hardware/master"; nixos-hardware.url = "github:nixos/nixos-hardware/master";
flake-utils.url = "github:numtide/flake-utils";
sops-nix = { sops-nix = {
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -12,17 +11,11 @@
tlaternet-webserver = { tlaternet-webserver = {
url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git"; url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git";
inputs = { inputs.nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
}; };
tlaternet-templates = { tlaternet-templates = {
url = "git+https://gitea.tlater.net/tlaternet/tlaternet-templates.git"; url = "git+https://gitea.tlater.net/tlaternet/tlaternet-templates.git";
inputs = { inputs.nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
}; };
}; };
@ -30,12 +23,12 @@
self, self,
nixpkgs, nixpkgs,
nixos-hardware, nixos-hardware,
flake-utils,
sops-nix, sops-nix,
tlaternet-webserver, tlaternet-webserver,
tlaternet-templates, tlaternet-templates,
... }: let
} @ inputs: let system = "x86_64-linux";
overlays = [ overlays = [
(final: prev: { (final: prev: {
tlaternet-webserver = tlaternet-webserver =
@ -47,13 +40,12 @@
}; };
}) })
]; ];
in
{ pkgs = import nixpkgs {inherit system overlays;};
sops-pkgs = sops-nix.packages.${system};
in {
nixosConfigurations = { nixosConfigurations = {
tlaternet = let tlaternet = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
@ -70,10 +62,7 @@
]; ];
}; };
vm = let vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
@ -102,31 +91,26 @@
]; ];
}; };
}; };
}
// flake-utils.lib.eachDefaultSystem (system: let devShells.${system}.default = pkgs.mkShell {
pkgs = import nixpkgs {inherit system overlays;};
sops-pkgs = sops-nix.packages.${system};
in {
devShell = pkgs.mkShell {
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"]; sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
nativeBuildInputs = with sops-pkgs; [ nativeBuildInputs = [
sops-import-keys-hook sops-pkgs.sops-import-keys-hook
]; ];
buildInputs = with pkgs; buildInputs = with pkgs; [
with sops-pkgs; [
nixfmt nixfmt
git-lfs git-lfs
sops-init-gpg-key sops-pkgs.sops-init-gpg-key
]; ];
shellHook = let shellHook = let
inherit (pkgs.lib.attrsets) mapAttrsToList; inherit (pkgs.lib.attrsets) mapAttrsToList;
inherit (pkgs.lib.strings) concatStringsSep; inherit (pkgs.lib.strings) concatStringsSep;
ports = { ports = {
"3022" = "2222"; "2222" = "2222";
"3080" = "80"; "3080" = "80";
"3443" = "443"; "3443" = "443";
"3021" = "2221"; "2221" = "2221";
"25565" = "25565";
"21025" = "21025"; # Starbound "21025" = "21025"; # Starbound
}; };
QEMU_NET_OPTS = QEMU_NET_OPTS =
@ -138,11 +122,10 @@
export QEMU_OPTS="-m 3941 -smp 2 -curses" export QEMU_OPTS="-m 3941 -smp 2 -curses"
export QEMU_NET_OPTS="${QEMU_NET_OPTS}" export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
# Work around sudo requiring a full terminal # Work around sudo requiring a full terminal when deploying to
# a remote host
export NIX_SSHOPTS="-t" export NIX_SSHOPTS="-t"
''; '';
}; };
};
packages = import ./pkgs {inherit pkgs;};
});
} }