Modularise deploy-rs and add home-manager configs

This commit is contained in:
2022-02-20 20:16:49 +00:00
parent 15b10f22cf
commit c258230d74
8 changed files with 151 additions and 46 deletions

View File

@@ -11,6 +11,10 @@
targets.genericLinux.enable = true;
my = {
deploy.node = {
hostname = "h.nul.ie";
sshOpts = [ "-4" "-p" "8022" ];
};
ssh.matchBlocks = {
home = {
host =

View File

@@ -2,5 +2,6 @@
home-manager.modules = {
common = ./common.nix;
gui = ./gui.nix;
deploy-rs = ./deploy-rs.nix;
};
}

View File

@@ -1,4 +1,4 @@
{ lib, pkgs, pkgs', inputs, options, config, ... }@args:
{ lib, pkgs, pkgs', inputs, config, ... }@args:
let
inherit (builtins) mapAttrs readFile;
inherit (lib) concatMapStrings concatStringsSep optionalAttrs versionAtLeast mkMerge mkIf mkDefault mkOption;
@@ -153,6 +153,7 @@ in
home = {
packages = with pkgs; [
file
tree
iperf3
];
@@ -170,7 +171,9 @@ in
(mkIf (config.my.isStandalone || !args.osConfig.home-manager.useGlobalPkgs) {
# Note: If globalPkgs mode is on, then these will be overridden by the NixOS equivalents of these options
nixpkgs = {
overlays = [ ];
overlays = [
inputs.deploy-rs.overlay
];
config = {
allowUnfree = true;
};

View File

@@ -0,0 +1,38 @@
{ lib, pkgs, config, ... }:
let
inherit (builtins) head;
inherit (lib) mkMerge mkIf mkDefault;
inherit (lib.my) mkBoolOpt';
cfg = config.my.deploy;
in
{
options.my.deploy = with lib.types; {
enable = mkBoolOpt' true "Whether to expose deploy-rs configuration for this home configuration.";
inherit (lib.my.deploy-rs) node;
generate = {
home.enable = mkBoolOpt' true "Whether to generate a deploy-rs profile for this home config.";
};
};
config = mkMerge [
{
my.deploy.enable = mkIf (!config.my.isStandalone) false;
}
(mkIf cfg.enable {
my.deploy.node = {
profiles = {
home = mkIf cfg.generate.home.enable {
path = pkgs.deploy-rs.lib.activate.home-manager { inherit (config.home) activationPackage; };
profilePath = "/nix/var/nix/profiles/per-user/${config.home.username}/profile";
};
};
sshUser = mkDefault config.home.username;
user = config.home.username;
sudo = mkDefault "sudo -u";
};
})
];
}