- 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
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
{
description = "web frontend for git";
inputs.nixpkgs.url = "github:nixos/nixpkgs";
outputs =
{ self, nixpkgs }:
let
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f {
inherit system;
pkgs = import nixpkgs { inherit system; };
}
);
in
{
packages = forAllSystems (
{ system, pkgs }:
let
legit = self.packages.${system}.legit;
files = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [ ./config.yaml ];
};
in
{
legit = pkgs.callPackage ./. { };
default = legit;
testing =
let
repos = pkgs.callPackage ./tests/k6/repos.nix { };
in
pkgs.writeShellApplication {
name = "legit-testing";
text = ''
${pkgs.lib.getExe legit} -config ${repos}/tests/k6/config.yaml
'';
runtimeInputs = with pkgs; [
git
legit
repos
];
};
}
);
homeManagerModules.default = import ./nix/home-manager-module.nix self;
nixosModules.default = import ./nix/nixos-module.nix self;
apps = forAllSystems (
{ system, pkgs }: {
k6 = {
type = "app";
program = pkgs.lib.getExe pkgs.k6;
};
dprint = {
type = "app";
program = pkgs.lib.getExe pkgs.dprint;
};
}
);
formatter = forAllSystems (
{ system, pkgs }:
pkgs.buildFHSEnv {
name = "fhs-dprint";
targetPkgs =
pkgs: with pkgs; [
# Formatter frontend.
# https://dprint.dev/
dprint
# > Official formatter for Nix code
# https://github.com/NixOS/nixfmt
nixfmt
# For "gofmt" command.
go
];
runScript = "dprint fmt";
}
);
devShells = forAllSystems (
{ system, pkgs }: {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
go
gopls
];
};
# For those who don't have podman on system.
podman =
let
conf = pkgs.stdenv.mkDerivation {
name = "podman-config-files";
# No source.
unpackPhase = "true";
postInstall = ''
mkdir $out
cat > $out/registries.conf <<EOF
unqualified-search-registries = ["docker.io"]
EOF
# This is meant to be copied under ~/.config/containers/
cat > $out/policy.json <<EOF
{
"default": [{ "type": "insecureAcceptAnything" }]
}
EOF
cat > $out/containers.conf <<EOF
[engine]
cgroup_manager="cgroupfs"
events_logger="file"
EOF
'';
};
in
pkgs.mkShell {
packages = with pkgs; [
podman
conf
];
shellHook = ''
if [[ ! -f ~/.config/containers/policy.json && ! -f /etc/containers/policy.json ]]; then
echo "Create policy.json file for podman."
echo "https://podman.io/docs/installation#policyjson"
echo "If you are okay with insecureAcceptAnything for all, run:"
echo "install -Dm555 ${conf}/policy.json ~/.config/containers/policy.json"
fi
'';
CONTAINERS_REGISTRIES_CONF = "${conf}/registries.conf";
CONTAINERS_CONF = "${conf}/containers.conf";
};
}
);
nixosConfigurations =
let
system = "x86_64-linux";
in
{
soft-legit = nixpkgs.lib.nixosSystem {
inherit system;
pkgs = import nixpkgs { inherit system; };
modules = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
./nix/nixos-configuration-soft-legit.nix
self.nixosModules.default
];
};
soft-legit-hm = nixpkgs.lib.nixosSystem {
inherit system;
pkgs = import nixpkgs { inherit system; };
modules = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
./nix/nixos-configuration-soft-legit-hm.nix
({ ... }: { home-manager.extraSpecialArgs.legit = self; })
];
};
};
};
}