deploy-rs: init support

Managing servers remotely is a big usecase, and deploy-rs is a flake
first deployment tool. By default, all nixosConfigurations are also
setup as deploy-rs nodes.

You'll still need to do some manual ssh setup, but other than that, the
system is ready to deploy.
This commit is contained in:
Timothy DeHerrera 2021-02-14 22:17:24 -07:00
parent cf23b8e64d
commit caba5fd756
No known key found for this signature in database
GPG key ID: 8985725DB5B0C122
5 changed files with 87 additions and 9 deletions

3
extern/default.nix vendored
View file

@ -8,6 +8,9 @@
overlays = [
nur.overlay
devshell.overlay
(final: prev: {
deploy-rs = deploy.packages.${prev.system}.deploy-rs;
})
];
# passed to all nixos modules

View file

@ -27,6 +27,35 @@
"type": "github"
}
},
"deploy": {
"inputs": {
"flake-compat": [
"flake-compat"
],
"naersk": [
"naersk"
],
"nixpkgs": [
"override"
],
"utils": [
"utils"
]
},
"locked": {
"lastModified": 1612864896,
"narHash": "sha256-pbsvxe05kAWJzPeC6fs4t0Mk8mTZs6u/WQDMBqoA5tA=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "fecc7e723db40c7e056371467275186b3bbb9ef3",
"type": "github"
},
"original": {
"owner": "serokell",
"repo": "deploy-rs",
"type": "github"
}
},
"devshell": {
"locked": {
"lastModified": 1612486691,
@ -79,6 +108,26 @@
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"override"
]
},
"locked": {
"lastModified": 1612192764,
"narHash": "sha256-7EnLtZQWP6511G1ZPA7FmJlqAr3hWsAYb24tvTvJ/ec=",
"owner": "nmattia",
"repo": "naersk",
"rev": "6e149bfd726a8ebefa415f2d713ba6d942435abd",
"type": "github"
},
"original": {
"owner": "nmattia",
"repo": "naersk",
"type": "github"
}
},
"nixos": {
"locked": {
"lastModified": 1612690903,
@ -156,9 +205,11 @@
"root": {
"inputs": {
"ci-agent": "ci-agent",
"deploy": "deploy",
"devshell": "devshell",
"flake-compat": "flake-compat",
"home": "home",
"naersk": "naersk",
"nixos": "nixos",
"nixos-hardware": "nixos-hardware",
"nur": "nur",

View file

@ -14,25 +14,33 @@
ci-agent.inputs.nixos-20_09.follows = "nixos";
ci-agent.inputs.nixos-unstable.follows = "override";
ci-agent.inputs.flake-compat.follows = "flake-compat";
deploy.url = "github:serokell/deploy-rs";
deploy.inputs.utils.follows = "utils";
deploy.inputs.naersk.follows = "naersk";
deploy.inputs.nixpkgs.follows = "override";
deploy.inputs.flake-compat.follows = "flake-compat";
naersk.url = "github:nmattia/naersk";
naersk.inputs.nixpkgs.follows = "override";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
};
outputs =
inputs@{ self
, ci-agent
inputs@{ ci-agent
, deploy
, devshell
, home
, nixos
, override
, utils
, nur
, devshell
, nixos-hardware
, nur
, override
, self
, utils
, ...
}:
let
inherit (utils.lib) eachDefaultSystem flattenTreeSystem;
inherit (nixos.lib) recursiveUpdate;
inherit (nixos.lib) recursiveUpdate mapAttrs;
inherit (self.lib) overlays nixosModules genPackages genPkgs
genHomeActivationPackages;
@ -63,6 +71,21 @@
templates.flk.description = "flk template";
defaultTemplate = self.templates.flk;
deploy.nodes = mapAttrs
(_: config: {
hostname = config.config.networking.hostName;
profiles.system = {
user = "root";
path = deploy.lib.x86_64-linux.activate.nixos config;
};
})
self.nixosConfigurations;
checks = builtins.mapAttrs
(system: deployLib: deployLib.deployChecks self.deploy)
deploy.lib;
};
systemOutputs = eachDefaultSystem (system:

View file

@ -12,6 +12,7 @@ in
binutils
coreutils
curl
deploy-rs
direnv
dnsutils
dosfstools
@ -22,8 +23,8 @@ in
iputils
jq
manix
nix-index
moreutils
nix-index
nmap
ripgrep
tealdeer

View file

@ -23,7 +23,7 @@ pkgs.devshell.mkShell {
nixos-install
nixos-generate-config
nixos-enter
];
] ++ lib.optional (system == "x86_64-linux") deploy-rs;
env = { inherit name; };