-
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
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
# Copyright 2026 Shota FUJI <pockawoooh@gmail.com>
# SPDX-License-Identifier: MIT
{
config,
lib,
pkgs,
...
}:
let
home-manager = builtins.fetchTarball {
url = "https://github.com/nix-community/home-manager/archive/4ce190229c73d44536caa7072f6308fb2d8feeb3.tar.gz";
sha256 = "1cqangi17i4nfkjpzpzpsavcgnaqdvarjjsjg09sbj5mnhnv6v35";
};
in
{
imports = [ (import "${home-manager}/nixos") ];
system.stateVersion = "26.11";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.firewall.enable = false;
users.users = {
alice = {
isNormalUser = true;
password = "pass";
};
};
security.polkit = {
enable = true;
# Password-less poweroff / reboot
extraConfig = ''
polkit.addRule(function(action, subject) {
const isPowerOff = [
"org.freedesktop.login1.reboot",
"org.freedesktop.login1.reboot-multiple-sessions",
"org.freedesktop.login1.power-off",
"org.freedesktop.login1.power-off-multiple-sessions",
].indexOf(action.id) > -1;
if (subject.user === "alice" && isPowerOff) {
return polkit.Result.YES;
}
})
'';
};
services.getty.autologinUser = "alice";
services.caddy = {
enable = true;
configFile = pkgs.writeText "Caddyfile" ''
{
auto_https off
}
:80 {
reverse_proxy :5555
}
'';
};
home-manager.useUserPackages = true;
home-manager.users.alice =
{
config,
lib,
pkgs,
legit,
...
}:
let
write-initial-admin-keys = pkgs.writeShellApplication {
name = "write-initial-admin-keys";
text = ''
echo "SOFT_SERVE_INITIAL_ADMIN_KEYS=\"$(cat)\"" > ${config.xdg.configHome}/soft-serve/admin.env
'';
};
in
{
imports = [ legit.homeManagerModules.default ];
home.stateVersion = "26.05";
# This is inevitable as we use fetched tarball along with nixpkgs managed by Flake.
home.enableNixpkgsReleaseCheck = false;
home.packages = with pkgs; [
curl
write-initial-admin-keys
];
services.legit = {
enable = true;
config = {
repo.scanPath = "${config.xdg.dataHome}/soft-serve/repos";
};
};
xdg.configFile."soft-serve/.keep" = {
text = "";
};
xdg.dataFile."soft-serve/config.yaml" =
let
yaml = pkgs.formats.yaml { };
in
{
source = yaml.generate "soft-serve.yaml" {
name = "soft-serve & legit HM module demo";
log_format = "text";
ssh.listen_addr = ":22222";
http.listen_addr = ":8080";
};
};
systemd.user.paths.soft-serve-adminenv = {
Unit = {
Description = "soft-serve initial admin env file";
};
Install = {
WantedBy = [ "default.target" ];
};
Path = {
PathExists = "${config.xdg.configHome}/soft-serve/admin.env";
Unit = "soft-serve.service";
};
};
systemd.user.services.soft-serve = {
Unit = {
Description = "Git server for the command-line";
After = [ "network.target" ];
};
Service = {
Type = "simple";
Restart = "always";
RestartSec = 1;
ExecStart = "${lib.getExe pkgs.soft-serve} serve";
Environment = "SOFT_SERVE_DATA_PATH=${config.xdg.dataHome}/soft-serve";
EnvironmentFile = "${config.xdg.configHome}/soft-serve/admin.env";
WorkingDirectory = "${config.xdg.dataHome}/soft-serve";
};
};
};
}