-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathflake.nix
More file actions
99 lines (83 loc) · 3.42 KB
/
flake.nix
File metadata and controls
99 lines (83 loc) · 3.42 KB
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
{
description = "try - fresh directories for every vibe";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
flake = {
homeModules.default = { config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.try;
in
{
options.programs.try = {
enable = mkEnableOption "try - fresh directories for every vibe";
package = mkOption {
type = types.package;
default = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default;
defaultText = literalExpression "inputs.self.packages.\${pkgs.stdenv.hostPlatform.system}.default";
description = ''
The try package to use. Can be overridden to customize Ruby version:
```nix
programs.try.package = inputs.try.packages.${"$"}{pkgs.stdenv.hostPlatform.system}.default.override {
ruby = pkgs.ruby_3_3;
};
```
'';
};
path = mkOption {
type = types.str;
default = "~/src/tries";
description = "Path where try directories will be stored.";
};
};
config = mkIf cfg.enable {
programs.bash.initExtra = mkIf config.programs.bash.enable ''
eval "$(${cfg.package}/bin/try init ${cfg.path})"
'';
programs.zsh.initContent = mkIf config.programs.zsh.enable ''
eval "$(${cfg.package}/bin/try init ${cfg.path})"
'';
programs.fish.shellInit = mkIf config.programs.fish.enable ''
eval (${cfg.package}/bin/try init ${cfg.path} | string collect)
'';
};
};
# Backwards compatibility - deprecated
homeManagerModules.default = builtins.trace
"WARNING: homeManagerModules is deprecated and will be removed in a future version. Please use homeModules instead."
inputs.self.homeModules.default;
};
perSystem = { config, self', inputs', pkgs, system, ... }: {
packages.default = pkgs.callPackage ({ ruby ? pkgs.ruby_3_3 }: pkgs.stdenv.mkDerivation rec {
pname = "try";
version = builtins.replaceStrings ["\n"] [""] (builtins.readFile ./VERSION);
src = inputs.self;
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
installPhase = ''
mkdir -p $out/bin
cp try.rb $out/bin/try
cp -r lib $out/bin/
chmod +x $out/bin/try
wrapProgram $out/bin/try \
--prefix PATH : ${ruby}/bin
'';
meta = with pkgs.lib; {
description = "Fresh directories for every vibe - lightweight experiments for people with ADHD";
homepage = "https://github.com/tobi/try";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.unix;
};
}) {};
apps.default = {
type = "app";
program = "${self'.packages.default}/bin/try";
};
};
};
}