diff --git a/flake.nix b/flake.nix index 0433804..15b99ba 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,11 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgsUnstable"; }; + # TODO: remove after https://github.com/nix-community/home-manager/pull/3811 + homeManagerGitWorkspace = { + url = "github:aciceri/home-manager/git-workspace"; + inputs.nixpkgs.follows = "nixpkgsUnstable"; + }; disko = { url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgsUnstable"; diff --git a/hmModules/git-workspace/default.nix b/hmModules/git-workspace/default.nix index 9d29ce6..dd14105 100644 --- a/hmModules/git-workspace/default.nix +++ b/hmModules/git-workspace/default.nix @@ -1,9 +1,4 @@ {age, ...}: { - imports = [ - ./git-workspace-program.nix - ./git-workspace-service.nix - ]; - programs.git-workspace.enable = true; services.git-workspace = { enable = true; diff --git a/hmModules/git-workspace/git-workspace-program.nix b/hmModules/git-workspace/git-workspace-program.nix deleted file mode 100644 index 717d768..0000000 --- a/hmModules/git-workspace/git-workspace-program.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.programs.git-workspace; -in { - options.programs.git-workspace = { - enable = lib.mkEnableOption "git-workspace"; - package = lib.mkOption { - type = lib.types.package; - default = pkgs.git-workspace; - description = "The git-workspace to use"; - }; - }; - config = lib.mkIf cfg.enable { - home.packages = [pkgs.git-workspace]; - }; -} diff --git a/hmModules/git-workspace/git-workspace-service.nix b/hmModules/git-workspace/git-workspace-service.nix deleted file mode 100644 index 0142c2c..0000000 --- a/hmModules/git-workspace/git-workspace-service.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.services.git-workspace; - tomlFormat = pkgs.formats.toml {}; -in { - options.services.git-workspace = { - enable = lib.mkEnableOption "git-workspace systemd timer"; - package = lib.mkOption { - type = lib.types.package; - default = - if config.programs.git-workspace.enable - then config.programs.git-workspace.package - else pkgs.git-workspace; - description = "The git-workspace to use"; - }; - frequency = lib.mkOption { - type = lib.types.str; - default = ""; - description = ""; - }; - environmentFile = lib.mkOption { - type = lib.types.path; - default = ""; - description = ""; - example = ""; - }; - workspaces = lib.mkOption { - type = lib.types.attrsOf tomlFormat.type; - default = {}; - description = "Workspaces verbatims"; - # example = { - # workspace-foo = { - # provider = [ - # { - # provider = "github"; - # name = ""; - # path = "..."; - # skip_forks = false; - # } - # ]; - # }; - # }; - }; - }; - config = lib.mkIf cfg.enable { - xdg.configFile = - lib.mapAttrs' (workspaceName: workspace: { - name = "git-workspace/${workspaceName}/workspace.toml"; - value.source = - (tomlFormat.generate "${workspaceName}-workspace.toml" workspace).outPath; - }) - cfg.workspaces; - systemd.user.services = - lib.mapAttrs' (workspaceName: workspace: rec { - name = "git-workspace-${workspaceName}-update"; - value = { - Unit.Description = "Runs `git-workspace update` for ${workspaceName}"; - Service = { - EnvironmentFile = cfg.environmentFile; - ExecStart = let - script = pkgs.writeShellApplication { - name = "${name}-launcher"; - text = '' - ${cfg.package}/bin/git-workspace \ - --workspace ${config.xdg.configHome}/git-workspace/${workspaceName} \ - update - ''; - runtimeInputs = with pkgs; [busybox openssh git]; - }; - in "${script}/bin/${name}-launcher"; - }; - }; - }) - cfg.workspaces; - systemd.user.timers = - lib.mapAttrs' (workspaceName: workspace: { - name = "git-workspace-${workspaceName}-update"; - value = { - Unit = { - Description = "Automatically runs `git-workspace update` for ${workspaceName}"; - }; - Timer = { - Unit = "git-workspace-${workspaceName}-update.unit"; - OnCalendar = cfg.frequency; - Persistent = true; - }; - Install.WantedBy = ["timers.target"]; - }; - }) - cfg.workspaces; - }; -} diff --git a/hosts/default.nix b/hosts/default.nix index 8b32ccc..677405f 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -170,6 +170,15 @@ extraModules = [inputs.disko.nixosModules.disko]; extraHmModules = [ inputs.ccrEmacs.hmModules.default + { + # TODO: remove after https://github.com/nix-community/home-manager/pull/3811 + imports = let + hmModules = "${inputs.homeManagerGitWorkspace}/modules"; + in [ + "${hmModules}/programs/git-workspace.nix" + "${hmModules}/services/git-workspace.nix" + ]; + } ]; secrets = { "git-workspace-tokens".owner = "ccr";