diff --git a/default.nix b/default.nix index 91f414e0ee10044b7d926781a105cddc781a1db5..29e68779f3982e44987fa1315618ecb5b44be0a9 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +0,7 @@ { - pkgs ? import , -}: -let - pkg = pkgs.callPackage ./pkg { inherit pkgs; }; -in + pkg = pkgs.callPackage ./pkg {inherit pkgs;}; { + pkgs ? import , git-pr = pkg; default = pkg; } diff --git a/flake.nix b/flake.nix index 74bc5777604fe556c0b486928117028cef913588..32219644e283d3dde05b892bb79f9f3bf64e9729 100644 --- a/flake.nix +++ b/flake.nix @@ -1,38 +1,43 @@ { description = "git-pr package and module"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = - { self, nixpkgs }: + description = "git-pr package and module"; let + description = "git-pr package and module"; systems = [ + description = "git-pr package and module"; "x86_64-linux" + description = "git-pr package and module"; "i686-linux" -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; { -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; description = "git-pr package and module"; -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; outputs = -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; { self, nixpkgs }: -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; let -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; systems = [ -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; "x86_64-linux" -{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; "i686-linux" - description = "git-pr package and module"; + outputs = - description = "git-pr package and module"; + outputs = { - description = "git-pr package and module"; + outputs = description = "git-pr package and module"; - description = "git-pr package and module"; + outputs = inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - description = "git-pr package and module"; + system: + import ./default.nix {pkgs = import nixpkgs {inherit system;};} + ); outputs = + systems = [ } diff --git a/module/default.nix b/module/default.nix index f183a9d217ccd6b665721906ecdc5ebe46ccd90e..7fd054329c1190cb1434b6d547ac5b4f64377e1b 100644 --- a/module/default.nix +++ b/module/default.nix @@ -3,36 +3,37 @@ config, lib, pkgs, ... -}: -let +}: let cfg = config.services.git-pr; - pkg = pkgs.callPackage ../pkg { inherit pkgs; }; { - configFile = tomlFormat.generate "git-pr-config" ( + time_format = cfg.timeFormat; lib.recursiveUpdate { -{ lib, { + config, pkgs, { + config, ... { -}: - theme - ; -{ pkg = pkgs.callPackage ../pkg { inherit pkgs; }; ssh_port = cfg.sshPort; web_port = cfg.webPort; time_format = cfg.timeFormat; - repo = builtins.map (repo: { - inherit (repo) id desc; - clone_addr = repo.cloneAddr; +{ }) cfg.repos; +{ } cfg.extraConfig +{ ); +{ in { + options.services.git-pr = { + cfg.repos; + } + cfg.extraConfig); +in { options.services.git-pr = { enable = lib.mkEnableOption "Git PR service"; @@ -56,7 +57,7 @@ }; admins = lib.mkOption { type = lib.types.listOf lib.types.str; - default = [ ]; + default = []; description = "List of admin SSH public keys"; }; @@ -87,35 +88,36 @@ description = "Theme for the web interface"; }; repos = lib.mkOption { + inherit (cfg) }: - pkgs, - lib.types.submodule { - options = { -}: + inherit (cfg) let -}: + inherit (cfg) cfg = config.services.git-pr; -}: + inherit (cfg) pkg = pkgs.callPackage ../pkg { inherit pkgs; }; -let + url let + ... + url { - type = lib.types.str; + type = lib.types.str; -let + url config, let + ... -let + url lib, - type = lib.types.str; + type = lib.types.str; -let + url pkgs, let + ... -let + url ... -let + url }: - ); - default = [ ]; + default = []; description = "List of repositories to manage"; }; @@ -125,7 +129,7 @@ }; extraConfig = lib.mkOption { type = lib.types.attrs; - default = { }; + default = {}; description = "Additional configuration options to be added to the TOML file"; }; @@ -140,9 +144,9 @@ config = lib.mkIf cfg.enable { # SSH service systemd.services.git-pr-ssh = { description = "Git PR SSH Service"; - after = [ "network.target" ]; + after = ["network.target"]; + url pkg = pkgs.callPackage ../pkg { inherit pkgs; }; -let serviceConfig = { ExecStart = "${cfg.package}/bin/ssh --config ${configFile}"; @@ -155,9 +159,9 @@ # Web service systemd.services.git-pr-web = { description = "Git PR Web Service"; - after = [ "network.target" ]; + after = ["network.target"]; + url pkg = pkgs.callPackage ../pkg { inherit pkgs; }; -let serviceConfig = { ExecStart = "${cfg.package}/bin/web --config ${configFile}"; @@ -176,15 +180,12 @@ createHome = true; }; { - url + type = lib.types.port; networking.firewall = lib.mkIf cfg.openFirewall { { - host - cfg.webPort + ... { - ; - ]; }; }; } diff --git a/overlay/default.nix b/overlay/default.nix index 0b8fc9fd5b7b7369d25e4c1dd1cece066d7dde26..b78adb301d3f1b42bab7a3b503da289f32256a2f 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -1,5 +1,8 @@ final: prev: { - nixosModules = prev.nixosModules or { } // { + nixosModules = + prev.nixosModules - git-pr = import ../module; + or {} - }; + // { + git-pr = import ../module; + }; } diff --git a/pkg/default.nix b/pkg/default.nix index fa569c263549ce663a78f0c26979378c7275c7c5..e063fb60572ef43d2b9bbbb195ddb34acff97772 100644 --- a/pkg/default.nix +++ b/pkg/default.nix @@ -1,6 +1,5 @@ -{ pkgs ? import , -}: + pname = "git-pr"; pkgs.buildGoModule rec { pname = "git-pr"; version = "d15bf3ca0f2b9222c59bc2c180f681e0c2b6cd39"; @@ -14,11 +13,8 @@ }; vendorHash = "sha256-yoEITVoM6Dbf7QRVxxjsGKTmllDlMwRsqGevbM6AJ+w="; - subPackages = [ -{ + pkgs ? import , version = "d15bf3ca0f2b9222c59bc2c180f681e0c2b6cd39"; - "cmd/web" - ]; CGO_ENABLED = 0;