Remove digga from b12f branch #257

Merged
b12f merged 4 commits from remove-digga/b12f into b12f 2023-10-03 12:23:15 +00:00
3 changed files with 93 additions and 17 deletions
Showing only changes of commit 08c6cb6e81 - Show all commits

View file

@ -69,6 +69,7 @@
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = [ buildInputs = [
pkgs.deploy-rs
pkgs.nixpkgs-fmt pkgs.nixpkgs-fmt
pkgs.agenix pkgs.agenix
pkgs.ssh-to-age pkgs.ssh-to-age
@ -141,19 +142,26 @@
]; ];
}; };
deploy.nodes = { deploy.nodes = self.b12f.lib.deploy.mkDeployNodes self.nixosConfigurations {
droppie.profiles.system = { chocolatebar = {
hostname = "backup.b12f.io"; sshUser = "b12f";
sshUser = "yule";
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.droppie;
}; };
pie.profiles.system = { biolimo = {
sshUser = "b12f";
};
droppie = {
hostname = "backup.b12f.io";
sshUser = "yule";
};
pie = {
hostname = "pie.local"; hostname = "pie.local";
sshUser = "yule"; sshUser = "yule";
}; };
maoam.profiles.system = { maoam = {
sshUser = "b12f"; sshUser = "b12f";
}; };
}; };

View file

@ -1,10 +1,16 @@
{lib}: { lib, inputs, ... }: {
lib.makeExtensible (self: let # Configuration common to all Linux systems
callLibs = file: import file {lib = self;}; flake = {
in rec { b12f.lib = let
## Define your own library functions here! callLibs = file: import file {inherit lib;};
#id = x: x; in rec {
## Or in files, containing functions that take {lib} ## Define your own library functions here!
#foo = callLibs ./foo.nix; #id = x: x;
## In configs, they can be used under "lib.our" ## Or in files, containing functions that take {lib}
}) #foo = callLibs ./foo.nix;
## In configs, they can be used under "lib.our"
deploy = import ./deploy.nix { inherit inputs lib; };
};
};
}

62
lib/deploy.nix Normal file
View file

@ -0,0 +1,62 @@
/*
* The contents of this file are adapted from digga
* https://github.com/divnix/digga
*
* Licensed under the MIT license
*/
{ lib, inputs }: let
getFqdn = c: let
net = c.config.networking;
fqdn =
if (net ? domain) && (net.domain != null)
then "${net.hostName}.${net.domain}"
else net.hostName;
in
fqdn;
in {
mkDeployNodes = systemConfigurations: extraConfig:
/*
*
Synopsis: mkNodes _systemConfigurations_ _extraConfig_
Generate the `nodes` attribute expected by deploy-rs
where _systemConfigurations_ are `nodes`.
_systemConfigurations_ should take the form of a flake's
_nixosConfigurations_. Note that deploy-rs does not currently support
deploying to darwin hosts.
_extraConfig_, if specified, will be merged into each of the
nodes' configurations.
Example _systemConfigurations_ input:
```
{
hostname-1 = {
fastConnection = true;
sshOpts = [ "-p" "25" ];
};
hostname-2 = {
sshOpts = [ "-p" "19999" ];
sshUser = "root";
};
}
```
*
*/
lib.recursiveUpdate
(lib.mapAttrs
(
_: c: {
hostname = getFqdn c;
profiles.system = {
user = "root";
path = inputs.deploy-rs.lib.${c.pkgs.stdenv.hostPlatform.system}.activate.nixos c;
};
}
)
systemConfigurations)
extraConfig;
}