-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
135 lines (118 loc) · 3.49 KB
/
flake.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
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
{
description = "Configuration for a NixOS disk image and zipfile to be consumed by the asahi-installer.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-apple-silicon = {
url = "github:tpwrules/nixos-apple-silicon";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
nixpkgs,
nixos-apple-silicon,
self,
...
}:
let
forEachSystem =
function:
nixpkgs.lib.genAttrs
[
"aarch64-darwin"
"aarch64-linux"
]
(
system:
function {
pkgs = import nixpkgs {
inherit system;
overlays = [ nixos-apple-silicon.overlays.default ];
};
}
);
secrets = builtins.fromJSON (builtins.readFile ./secrets.json);
in
{
packages = forEachSystem (
{ pkgs }:
{
installerPackage = pkgs.callPackage ./package.nix { inherit self pkgs; };
nixosImage =
let
image-config = nixpkgs.lib.nixosSystem rec {
system = "aarch64-linux";
pkgs = import nixpkgs { inherit system; };
specialArgs = {
modulesPath = nixpkgs + "/nixos/modules";
};
modules = [
nixos-apple-silicon.nixosModules.default
./modules/image-config.nix
];
};
config = image-config.config;
in
config.system.build.image;
}
);
apps = forEachSystem (
{ pkgs }:
rec {
default = upload;
upload = {
type = "app";
program = import ./app.nix { inherit pkgs secrets self; };
};
decrypt =
let
inherit (pkgs) lib writeShellApplication;
in
with lib;
{
type = "app";
program = getExe (writeShellApplication {
name = "decrypt-secrets";
runtimeInputs = [ pkgs.git-crypt ];
text = ''
[[ $# -gt 0 ]] || exit 1
base64 -d <<< "$1" | git-crypt unlock -
'';
});
};
}
);
devShells = forEachSystem (
{ pkgs }:
let
inherit (pkgs) mkShell;
in
rec {
default = boto3;
boto3 = mkShell {
name = "boto3";
packages = with pkgs; [ (python3.withPackages (ps: [ ps.boto3 ])) ];
shellHook = ''
ACCESS_KEY_ID="${secrets.accessKeyId}"; export ACCESS_KEY_ID
ACCOUNT_ID="${secrets.accountId}"; export ACCOUNT_ID
BUCKET_NAME="${secrets.bucketName}"; export BUCKET_NAME
ENDPOINT_URL="https://$ACCOUNT_ID.r2.cloudflarestorage.com"; export ENDPOINT_URL
SECRET_ACCESS_KEY="${secrets.secretAccessKey}"; export SECRET_ACCESS_KEY
'';
};
}
);
formatter = forEachSystem (pkgs: pkgs.nixfmt-rfc-style);
};
nixConfig = {
extra-substituters = [
"https://nixos-asahi.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nixos-asahi.cachix.org-1:CPH9jazpT/isOQvFhtAZ0Z18XNhAp29+LLVHr0b2qVk="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
download-buffer-size = 134217728;
};
}