From ae75e2a578e68a0948a5cea1097cc380ea10bde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sat, 8 Jun 2019 15:05:19 +0200 Subject: [PATCH] - declarative git, since that is now managed by mr --- configs/git.nix | 12 --------- example-git.nix | 14 ---------- modules/git.nix | 68 ------------------------------------------------- 3 files changed, 94 deletions(-) delete mode 100644 example-git.nix delete mode 100644 modules/git.nix diff --git a/configs/git.nix b/configs/git.nix index 52eaa7a..51216a3 100644 --- a/configs/git.nix +++ b/configs/git.nix @@ -1,17 +1,5 @@ { pkgs, config, ... }: { - imports = [ ]; - - # 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 diff --git a/example-git.nix b/example-git.nix deleted file mode 100644 index cdae1cf..0000000 --- a/example-git.nix +++ /dev/null @@ -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"; } ]; - }; - }; -} diff --git a/modules/git.nix b/modules/git.nix deleted file mode 100644 index 74a65ad..0000000 --- a/modules/git.nix +++ /dev/null @@ -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; - }; -}