Skip to content

Commit 8496519

Browse files
jim3692IceDBorn
authored andcommitted
feat(cache): implement nixos substituter (#62)
1 parent f8b5b8f commit 8496519

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
inputs = {
3+
cache-server = {
4+
flake = false;
5+
url = "github:icedos/cache-server";
6+
};
7+
38
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
49
};
510

modules/cache.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ config, lib, ... }:
2+
3+
let
4+
inherit (lib) mkIf;
5+
6+
inherit (config.icedos.system.cache)
7+
enable
8+
key
9+
url
10+
priority
11+
;
12+
in
13+
{
14+
nix.settings = mkIf enable {
15+
substituters = [ "${url}?priority=${toString priority}" ];
16+
trusted-public-keys = [ key ];
17+
};
18+
}

modules/options.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}:
77

88
let
9-
inherit (lib) types;
9+
inherit (lib) readFile types;
1010

1111
inherit (icedosLib)
1212
mkBoolOption
@@ -90,6 +90,17 @@ in
9090
resolution = mkStrOption { default = "1920x1080"; };
9191
};
9292

93+
cache = {
94+
enable = mkBoolOption { default = true; };
95+
url = mkStrOption { default = "https://icedos.mirrors.knp.one/icedos"; };
96+
97+
key = mkStrOption {
98+
default = readFile "${inputs.icedos-core.inputs.cache-server}/nix-public.pem";
99+
};
100+
101+
priority = mkNumberOption { default = 100; };
102+
};
103+
93104
channels = mkSubmoduleListOption { default = [ ]; } {
94105
name = mkStrOption { };
95106
url = mkStrOption { };

0 commit comments

Comments
 (0)