add module, fix 'nix-build'

This commit is contained in:
Aaron Bieber 2023-05-22 19:39:52 -06:00
parent aa16335095
commit 25540cad90
No known key found for this signature in database
3 changed files with 80 additions and 7 deletions

View File

@ -1,5 +1,6 @@
{
description = "pr-status: a tool to query NixOS/nixpkgs pull request status as they move along the build chain";
description =
"pr-status: a tool to query NixOS/nixpkgs pull request status as they move along the build chain";
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
@ -10,16 +11,17 @@
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in {
overlay = final: prev: {
pr-status = self.packages.${prev.system}.pr-status;
};
nixosModule = import ./module.nix;
packages = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {
pr-status = pkgs.stdenv.mkDerivation {
pr-status = pkgs.perlPackages.buildPerlPackage {
pname = "pr-status";
version = "v0.0.1";
src = ./.;
buildInputs = with pkgs.perlPackages; [ PerlTidy ];
nativeBuildInputs = with pkgs.perlPackages; [ perl ];
propagatedBuildInputs = with pkgs.perlPackages; [
Mojolicious
JSON
@ -30,7 +32,8 @@
};
});
defaultPackage = forAllSystems (system: self.packages.${system}.pr-status);
defaultPackage =
forAllSystems (system: self.packages.${system}.pr-status);
devShells = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {

70
module.nix Normal file
View File

@ -0,0 +1,70 @@
{ lib, config, pkgs, ... }:
let cfg = config.services.pr-status;
in {
options = with lib; {
services.pr-status = {
enable = lib.mkEnableOption "Enable pr-status";
port = mkOption {
type = types.int;
default = 3003;
description = ''
Port to listen on
'';
};
user = mkOption {
type = with types; oneOf [ str int ];
default = "pr-status";
description = ''
The user the service will use.
'';
};
group = mkOption {
type = with types; oneOf [ str int ];
default = "pr-status";
description = ''
The group the service will use.
'';
};
package = mkOption {
type = types.package;
default = pkgs.pr-status;
defaultText = literalExpression "pkgs.pr-status";
description = "The package to use for pr-status";
};
};
};
config = lib.mkIf (cfg.enable) {
users.groups.${cfg.group} = { };
users.users.${cfg.user} = {
description = "pr-status service user";
isSystemUser = true;
home = "/var/lib/pr-status";
createHome = true;
group = "${cfg.group}";
};
systemd.services.pr-status = {
enable = true;
description = "pr-status server";
wantedBy = [ "network-online.target" ];
after = [ "network-online.target" ];
environment = { HOME = "/var/lib/pr-status"; };
serviceConfig = {
User = cfg.user;
Group = cfg.group;
ExecStart =
"${cfg.package}/bin/pr-status.pl daemon -m production -l http://127.0.0.1:${
toString cfg.port
}";
};
};
};
}

View File

@ -14,7 +14,7 @@ use Time::HiRes qw( time );
my $VERSION = 'v0.0.1';
my $repo_dir = "/home/qbit/gostart_nixpkgs";
my $repo_dir = "/var/lib/pr-status/nixpkgs";
$ENV{"GIT_CONFIG_SYSTEM"} = ""; # Ignore insteadOf rules
$ENV{"HOME"} = "/tmp"; # Ignore ~/.netrc