From fca8b6d29cb9f4b29c3d7358f06937846ab40002 Mon Sep 17 00:00:00 2001 From: uku Date: Sun, 23 Jun 2024 22:48:22 +0200 Subject: [PATCH] chore: replace deploy-rs with nixinate --- configs/server.nix | 10 +++++++++- flake.lock | 46 +++++++++++++++++++++------------------------- flake.nix | 38 +++++++++++++++++++++++++++++--------- justfile | 14 ++++---------- parts/default.nix | 6 ------ parts/deploy.nix | 37 ------------------------------------- parts/dev.nix | 14 -------------- 7 files changed, 63 insertions(+), 102 deletions(-) delete mode 100644 parts/default.nix delete mode 100644 parts/deploy.nix delete mode 100644 parts/dev.nix diff --git a/configs/server.nix b/configs/server.nix index ebd3c6e..a33375a 100644 --- a/configs/server.nix +++ b/configs/server.nix @@ -1,4 +1,12 @@ -{ +{config, ...}: { + _module.args.nixinate = { + host = config.networking.hostName; + sshUser = "root"; + buildOn = "remote"; + substituteOnTarget = true; + hermetic = true; + }; + services = { tailscale.extraUpFlags = ["--advertise-exit-node"]; diff --git a/flake.lock b/flake.lock index 081f059..9839966 100644 --- a/flake.lock +++ b/flake.lock @@ -86,30 +86,6 @@ "type": "github" } }, - "deploy-rs": { - "inputs": { - "flake-compat": [], - "nixpkgs": [ - "nixpkgs" - ], - "utils": [ - "flake-utils" - ] - }, - "locked": { - "lastModified": 1718194053, - "narHash": "sha256-FaGrf7qwZ99ehPJCAwgvNY5sLCqQ3GDiE/6uLhxxwSY=", - "owner": "serokell", - "repo": "deploy-rs", - "rev": "3867348fa92bc892eba5d9ddb2d7a97b9e127a8a", - "type": "github" - }, - "original": { - "owner": "serokell", - "repo": "deploy-rs", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -340,6 +316,26 @@ "type": "github" } }, + "nixinate": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708891350, + "narHash": "sha256-VOQrKK7Df/IVuNki+NshVuGkTa/Tw0GigPjWcZff6kk=", + "owner": "matthewcroughan", + "repo": "nixinate", + "rev": "452f33c60df5b72ad0858f5f2cf224bdf1f17746", + "type": "github" + }, + "original": { + "owner": "matthewcroughan", + "repo": "nixinate", + "type": "github" + } + }, "nixos-wsl": { "inputs": { "flake-compat": [], @@ -417,12 +413,12 @@ "api-rs": "api-rs", "catppuccin": "catppuccin", "crane": "crane", - "deploy-rs": "deploy-rs", "flake-parts": "flake-parts", "flake-utils": "flake-utils", "ghostty": "ghostty", "home-manager": "home-manager", "lanzaboote": "lanzaboote", + "nixinate": "nixinate", "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs", "systems": "systems_3", diff --git a/flake.nix b/flake.nix index acfa2f1..6d91de6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,15 +1,37 @@ { description = "example flake idk"; - outputs = {flake-parts, ...} @ inputs: + outputs = { + self, + flake-parts, + nixinate, + ... + } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { systems = ["x86_64-linux"]; imports = [ - ./parts ./systems ./exprs ]; + + perSystem = { + pkgs, + system, + ... + }: { + apps = (nixinate.nixinate.${system} self).nixinate; + + devShells.default = pkgs.mkShellNoCC { + packages = with pkgs; [ + just + statix + nix-output-monitor + ]; + }; + + formatter = pkgs.alejandra; + }; }; inputs = { @@ -30,13 +52,6 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - deploy-rs = { - url = "github:serokell/deploy-rs"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.utils.follows = "flake-utils"; - inputs.flake-compat.follows = ""; - }; - flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; @@ -64,6 +79,11 @@ inputs.flake-compat.follows = ""; }; + nixinate = { + url = "github:matthewcroughan/nixinate"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixos-wsl = { url = "github:nix-community/NixOS-WSL"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/justfile b/justfile index 1602b14..35db5c5 100644 --- a/justfile +++ b/justfile @@ -1,21 +1,15 @@ -# Shamelessly taken from https://github.com/getchoo/flake/blob/d80d49cc7652ea84810c4688212c48277dfc71be/justfile - -alias c := check alias s := switch alias d := deploy -default: - @just --choose - check: nix flake check -[linux] switch *args: - sudo nixos-rebuild switch --flake . --keep-going {{ args }} + @sudo -v + sudo nixos-rebuild switch --flake . --keep-going {{args}} --log-format internal-json |& nom --json deploy system: - deploy -s .#{{ system }} + nix run .#{{system}} lint *args: - statix check -i flake.nix **/hardware-configuration.nix {{ args }} + statix check -i flake.nix **/hardware-configuration.nix {{args}} diff --git a/parts/default.nix b/parts/default.nix deleted file mode 100644 index ef23bca..0000000 --- a/parts/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./deploy.nix - ./dev.nix - ]; -} diff --git a/parts/deploy.nix b/parts/deploy.nix deleted file mode 100644 index 3bf843d..0000000 --- a/parts/deploy.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - lib, - self, - inputs, - ... -}: let - systems = ["etna"]; - - getDeploy = pkgs: - (pkgs.appendOverlays [ - inputs.deploy-rs.overlay - (_: prev: { - deploy-rs = { - inherit (pkgs) deploy-rs; - inherit (prev.deploy-rs) lib; - }; - }) - ]) - .deploy-rs; - - toDeployNode = hostname: system: { - inherit hostname; - sshUser = "root"; - - profiles.system.path = let deploy = getDeploy system.pkgs; in deploy.lib.activate.nixos system; - }; -in { - flake = { - deploy = { - remoteBuild = true; - fastConnection = false; - nodes = lib.mapAttrs toDeployNode (lib.getAttrs systems self.nixosConfigurations); - }; - - checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib; - }; -} diff --git a/parts/dev.nix b/parts/dev.nix deleted file mode 100644 index 0eeea73..0000000 --- a/parts/dev.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - perSystem = {pkgs, ...}: { - devShells.default = pkgs.mkShellNoCC { - packages = with pkgs; [ - just - nil - statix - deploy-rs - ]; - }; - - formatter = pkgs.alejandra; - }; -}