1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

- declarative git, since that is now managed by mr

This commit is contained in:
Kierán Meinhardt
2019-06-08 15:05:19 +02:00
parent 02ed574be6
commit ae75e2a578
3 changed files with 0 additions and 94 deletions

View File

@@ -1,17 +1,5 @@
{ pkgs, config, ... }:
{
imports = [ <modules/git.nix> ];
# niveum.git = {
# enable = true;
# repositories.niveum = {
# enable = true;
# location = "/tmp/niveum";
# branches = [ "master" ];
# remotes.origin = "git@github.com:kmein/niveum";
# };
# };
environment.systemPackages = [
pkgs.mr
pkgs.git

View File

@@ -1,14 +0,0 @@
{
imports = [ modules/git.nix ];
niveum.git = {
enable = true;
repositories.niveum = {
enable = true;
location = "/home/kfm/prog/git/niveum";
remotes.origin = https://github.com/kmein/niveum;
branches = [ "master" ];
autoFetch = [ { remote = "origin"; branch = "master"; } ];
};
};
}

View File

@@ -1,68 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.niveum.git;
repositoryService = name: repository: nameValuePair "git-repository-${name}" {
enable = repository.enable;
startAt = "*/3:0";
wants = [ (if (repository.autoFetch != {}) then "network-online.target" else "multi-user.target") ];
after = [ (if (repository.autoFetch != {}) then "network-online.target" else "multi-user.target") ];
serviceConfig = {
Type = "oneshot";
RandomizedDelaySec = "300";
};
script =
let
branchSetup = flip map repository.branches (branch: ''
${pkgs.git}/bin/git branch ${branch}
'');
remoteSetup = concatStringsSep "\n" (flip mapAttrsToList repository.remotes (name: url: ''
${pkgs.git}/bin/git remote add ${name} ${url}
''));
fetch = concatStringsSep "\n" (flip map repository.autoFetch ({ branch, remote }: ''
${pkgs.git}/bin/git fetch ${remote} ${branch}
''));
repositorySetup = ''
if [ ! -d ${repository.location}/.git ]; then
${pkgs.git}/bin/git clone ${repository.remotes.origin} ${repository.location}
fi
'';
in ''
${repositorySetup}
cd ${repository.location}
${branchSetup}
${remoteSetup}
${fetch}
'';
};
in {
options.niveum.git = {
enable = mkEnableOption "declarative repository management";
repositories = mkOption {
type = types.attrsOf (types.submodule {
options = {
enable = mkEnableOption "git repository";
location = mkOption { type = types.path; };
remotes = mkOption { type = types.attrsOf types.path; default = {}; };
branches = mkOption { type = types.listOf types.str; default = []; };
autoFetch = mkOption {
type = types.listOf (types.submodule {
options = {
branch = mkOption { type = types.str; };
remote = mkOption { type = types.str; };
};
});
default = {};
};
};
});
default = {};
};
};
config = mkIf cfg.enable {
systemd.services = attrsets.mapAttrs' repositoryService cfg.repositories;
};
}