-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
146 lines (130 loc) · 3.59 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
136
137
138
139
140
141
142
143
144
145
146
{
description = "home-manager activation";
inputs = {
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = inputs @ {
nixpkgs,
home-manager,
flake-utils,
...
}: let
systems =
if builtins.hasAttr "currentSystem" builtins
then [builtins.currentSystem]
else
with flake-utils.lib; [
system.aarch64-darwin
system.aarch64-linux
system.x86_64-darwin
system.x86_64-linux
];
nixosHosts = [
"tpad"
"wsl"
];
home-manager-module = host: {
home-manager = {
verbose = true;
# Install packages to /etc/profiles; needed to run `nixos-rebuild build-vm`.
useUserPackages = true;
useGlobalPkgs = true;
users.${username} = {...}: {
imports = [
inputs.nix-index-database.hmModules.nix-index
config/home-manager/${host}.nix
];
};
};
};
overlay = self: super:
{
merriam-webster-1913 = self.stdenv.mkDerivation {
name = "merriam-webster-1913";
sourceRoot = ".";
src = self.fetchurl {
url = "https://s3.amazonaws.com/jsomers/dictionary.zip";
sha256 = "09y673q5v46ps72pnm1jz0jx2bcyfbsmzw3f2x9y9s99k3yf79ps";
};
nativeBuildInputs = [self.unzip];
installPhase = ''
mkdir -p "$out/dic"
tar -C "$out/dic" -xf dictionary/stardict-dictd-web1913-2.4.2.tar.bz2
'';
};
sdcv = self.symlinkJoin {
name = "sdcv";
paths = [super.sdcv];
buildInputs = [self.makeWrapper];
postBuild = ''
wrapProgram $out/bin/sdcv \
--set STARDICT_DATA_DIR "${self.merriam-webster-1913}"
'';
};
xmllint = self.libxml2;
}
// super.lib.attrsets.genAttrs [
"cabal-fmt"
"eventlog2html"
"ghc-events"
"ghc-events-analyze"
"lentil"
"profiteur"
"stylish-haskell"
"threadscope"
] (name: self.haskell.lib.justStaticExecutables self.haskellPackages.${name});
username = "cyd";
in
flake-utils.lib.eachSystem systems (
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [overlay];
};
lib = pkgs.lib;
homeManagerConfiguration = path:
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
inputs.nix-index-database.hmModules.nix-index
path
];
};
in {
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
git
just
];
shellHook = ''
scripts/init
'';
};
};
packages = {
# Installed via `home-manager switch --flake ".#HOSTNAME"`
homeConfigurations =
lib.attrsets.genAttrs nixosHosts (host:
homeManagerConfiguration config/home-manager/${host}.nix);
};
}
)
// {
darwinModules =
nixpkgs.lib.attrsets.genAttrs ["ts"] home-manager-module;
nixosModules =
nixpkgs.lib.attrsets.genAttrs nixosHosts home-manager-module;
overlays = {
default = overlay;
};
};
}