forked from lucabrunox/nixpaste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nixos-module.nix
53 lines (43 loc) · 1011 Bytes
/
nixos-module.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.nixpaste;
nixpaste = import ./default.nix ({ inherit pkgs; } // cfg.config);
in
{
options = {
services.nixpaste = {
enable = mkOption {
default = false;
type = types.bool;
};
config = mkOption {
default = {};
type = types.attrs;
};
user = mkOption {
default = "nixpaste";
type = types.str;
};
uid = mkOption {
default = 2001;
type = types.int;
};
};
};
config = mkIf cfg.enable {
systemd.services.nixpaste = {
wantedBy = [ "multi-user.target" ];
serviceConfig.User = cfg.user;
serviceConfig.ExecStart = "${nixpaste}/bin/nixpaste";
};
users.extraUsers = optional (cfg.user == "nixpaste") {
name = cfg.user;
group = "users";
uid = cfg.uid;
createHome = true;
home = "/home/nixpaste";
shell = "/run/current-system/sw/bin/bash";
};
};
}