From 99bd9d76a62d4a57c0882dd5d1739c12cbc94f9f Mon Sep 17 00:00:00 2001 From: Roy Dumblauskas Date: Sun, 1 Jun 2025 22:04:21 -0500 Subject: [PATCH] restore flake.nix --- nixos/flake.lock | 277 ++++++++++++++++++++++++++++++++++++++++++++++- nixos/flake.nix | 180 ++++++++++-------------------- 2 files changed, 331 insertions(+), 126 deletions(-) diff --git a/nixos/flake.lock b/nixos/flake.lock index 9ae40cc..1234e86 100644 --- a/nixos/flake.lock +++ b/nixos/flake.lock @@ -1,5 +1,46 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748832438, + "narHash": "sha256-/CtyLVfNaFP7PrOPrTEuGOJBIhcBKVQ91KiEbtXJi0A=", + "owner": "nix-community", + "repo": "disko", + "rev": "58d6e5a83fff9982d57e0a0a994d4e5c0af441e4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -18,7 +59,106 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747688870, + "narHash": "sha256-ypL9WAZfmJr5V70jEVzqGjjQzF0uCkz+AFQF7n9NmNc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "d5f1f641b289553927b3801580598d200a501863", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.11", + "repo": "home-manager", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748294338, + "narHash": "sha256-FVO01jdmUNArzBS7NmaktLdGA5qA3lUMJ4B7a05Iynw=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "cc5f390f7caf265461d4aab37e98d2292ebbdb85", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.8", + "repo": "ixx", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1748421225, + "narHash": "sha256-XXILOc80tvlvEQgYpYFnze8MkQQmp3eQxFbTzb3m/R0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "78add7b7abb61689e34fc23070a8f55e1d26185b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1748406211, + "narHash": "sha256-B3BsCRbc+x/d0WiG1f+qfSLUy+oiIfih54kalWBi+/M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3d1f29646e4b57ed468d60f9d286cde23a8d1707", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1748421225, "narHash": "sha256-XXILOc80tvlvEQgYpYFnze8MkQQmp3eQxFbTzb3m/R0=", @@ -34,10 +174,94 @@ "type": "github" } }, - "root": { + "nixvim": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_2", + "nuschtosSearch": "nuschtosSearch", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1748564405, + "narHash": "sha256-uCmQLJmdg0gKWBs+vhNmS9RIPJW8/ddo6TvQ/a4gupc=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "8b3a69cfea5ba2fa008c6c57ab79c99c513a349b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748298102, + "narHash": "sha256-PP11GVwUt7F4ZZi5A5+99isuq39C59CKc5u5yVisU/U=", + "owner": "NuschtOS", + "repo": "search", + "rev": "f8a1c221afb8b4c642ed11ac5ee6746b0fe1d32f", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, + "quasiSecrets": { + "locked": { + "lastModified": 1748827872, + "narHash": "sha256-l5vEHHoG0X49ZaAi/dlyVidrgRl+uY2sTHSXiPStoUA=", + "ref": "refs/heads/main", + "rev": "f6dad37607b8044097d2f8700aee755e4268a6ce", + "revCount": 14, + "type": "git", + "url": "ssh://git@github.com/RoyDumblauskas/server-semi-secrets" + }, + "original": { + "type": "git", + "url": "ssh://git@github.com/RoyDumblauskas/server-semi-secrets" + } + }, + "root": { + "inputs": { + "disko": "disko", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim", + "quasiSecrets": "quasiSecrets", + "sops-nix": "sops-nix", + "tests-service": "tests-service" + } + }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747603214, + "narHash": "sha256-lAblXm0VwifYCJ/ILPXJwlz0qNY07DDYdLD+9H+Wc8o=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "8d215e1c981be3aa37e47aeabd4e61bb069548fd", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" } }, "systems": { @@ -54,6 +278,55 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "tests-service": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1748833284, + "narHash": "sha256-FM9LIsGBx9lYjggcUy8jgh3vJ79+DQGDNYoSBINe3L8=", + "owner": "RoyDumblauskas", + "repo": "tests-service", + "rev": "7dbf79ace0d0bdd03a9a71e72439ae71ff0bbde6", + "type": "github" + }, + "original": { + "owner": "RoyDumblauskas", + "repo": "tests-service", + "type": "github" + } } }, "root": "root", diff --git a/nixos/flake.nix b/nixos/flake.nix index 73b096b..399dc5f 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -1,133 +1,65 @@ { - description = "tests-service for Roy's Homelab"; + description = "Server Config Controller"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; - flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + nixvim.url = "github:nix-community/nixvim"; + quasiSecrets.url = "git+ssh://git@github.com/RoyDumblauskas/server-semi-secrets"; + home-manager = { + url = "github:nix-community/home-manager/release-24.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + sops-nix = { + url = "github:Mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # This is a path to the services I've declared. + # It just happens to be stored in the same repository (relative), + # but could well be a separate repository + tests-service = { + url = "github:RoyDumblauskas/tests-service"; + }; }; - outputs = { - self, - nixpkgs, - flake-utils, - }: let - nixosModule = { - config, - lib, - pkgs, - ... - }: { - options.services.tests-service = { - enable = lib.mkEnableOption "Status reports for all homelab services"; - - port = lib.mkOption { - type = lib.types.port; - default = 8080; - description = "Port to listen on"; - }; - - default-nginx = { - enable = lib.mkEnableOption "Enable nginx reverse proxy to direct to service"; - hostname = { - type = lib.types.str; - default = "localhost"; - description = "Hostname to attach to service"; + outputs = { self, nixpkgs, nixvim, home-manager, disko, sops-nix, quasiSecrets, tests-service }@inputs: + let + nodes = [ + { + name = "nixos-homelab-00"; + hostId = "3884D2F1"; + } + ]; + in { + nixosConfigurations = builtins.listToAttrs (map (node: { + name = node.name; + value = nixpkgs.lib.nixosSystem { + specialArgs = { + meta = { + hostname = node.name; + hostId = node.hostId; }; }; - }; - - config = lib.mkIf config.services.tests-service.enable { - systemd.services.tests-service = { - description = "Status page for homelab services"; - wantedBy = ["multi-user.target"]; - after = ["network.target"]; - serviceConfig = { - ExecStart = "${pkgs.simple-http-server}/bin/tests-service --port ${ toString config.services.tests-service.port }"; - Restart = "always"; - Type = "simple"; - DynamicUser = "yes"; - WorkingDirectory = "${self.packages.${pkgs.system}.default}"; - }; - }; - - services.nginx = lib.mkIf config.services.tests-service.default-nginx.enable { - enable = true; - virtualHosts."${config.services.tests-service.default-nginx.hostname}" = { - forceSSL = true; - enableACME = true; - acmeRoot = null; - locations."/" = { - proxyPass = "http://localhost:${toString config.services.tests-service.port}"; - extraConfig = '' - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - ''; - }; - }; - }; - - networking.firewall.allowedTCPPorts = lib.mkMerge [ - (lib.mkIf config.services.tests-service.enable [ config.services.tests-service.port ]) - (lib.mkIf config.services.tests-service.default-nginx.enable [ 80 443 ]) + system = "x86_64-linux"; + modules = [ + ./configuration.nix + ./hardware-configuration.nix + ./disk-config.nix + disko.nixosModules.disko + sops-nix.nixosModules.sops + quasiSecrets.nixosModules.ipAddrs + quasiSecrets.nixosModules.serviceList + tests-service.nixosModules."x86_64-linux" + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.sysAdmin = ./home.nix; + } ]; - }; - }; - in - (flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; - - dioxusApp = pkgs.stdenv.mkDerivation { - pname = "tests-service"; - version = "0.1.0"; - src = ./.; - - buildInputs = with pkgs; [ - dioxus-cli - rustc - cargo - - # tauri deps? - pkg-config - gobject-introspection - cargo-tauri - nodejs - at-spi2-atk - atkmm - cairo - gdk-pixbuf - glib - gtk3 - harfbuzz - librsvg - libsoup_3 - pango - webkitgtk_4_1 - openssl - wasm-pack - wasm-bindgen-cli - lld - ]; - - buildPhase = '' - dx build --release - ''; - - installPhase = '' - mkdir -p $out - cp -r dist/* $out/ - ''; - }; - in { - packages.default = dioxusApp; - - apps.default = { - type = "app"; - program = "${dioxusApp}/index.html"; - }; - })) - // { - nixosModules.default = nixosModule; - }; + }; + }) nodes); + }; }