-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflake.nix
81 lines (75 loc) · 2.35 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
{
description = "faster shell navigation of projects";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
});
in
{
packages = forEachSupportedSystem ({ pkgs, ... }: {
default = import ./default.nix { inherit pkgs; };
});
darwinModules.default = { lib, config, pkgs, ... }:
let
h = self.packages.${pkgs.stdenv.system}.default;
in
{
options = {
programs.h.codeRoot = lib.mkOption {
type = lib.types.str;
default = "~/src";
description = lib.mdDoc ''
Root location for checking out your code.
'';
};
};
config = {
environment.systemPackages = [ h ];
environment.extraInit = ''
eval "$(${h}/bin/h --setup ${lib.escapeShellArg config.programs.h.codeRoot})"
'';
};
};
homeModules.default = { lib, config, pkgs, ... }:
let
h = self.packages.${pkgs.stdenv.system}.default;
in
{
options = {
programs.h.codeRoot = lib.mkOption {
type = lib.types.str;
default = "~/src";
description = lib.mdDoc ''
Root location for checking out your code.
'';
};
};
config = let
hook = ''
eval "$(${h}/bin/h --setup ${lib.escapeShellArg config.programs.h.codeRoot})"
'';
in {
home.packages = [ h ];
programs.bash.initExtra = hook;
programs.zsh.initExtra = hook;
programs.fish.functions.h = {
body = ''
set _h_dir $(${h}/bin/h --resolve $(path resolve ${config.programs.h.codeRoot}) $argv)
set _h_ret $status
if test "$_h_dir" != "$PWD"
cd "$_h_dir"
end
return $_h_ret
'';
wraps = "h";
};
};
};
};
}