-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
128 lines (114 loc) · 4.79 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
{
description = "Overall Linux Environment for Computer Related to MultiHop";
# inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05"; };
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
};
outputs = { self, nixpkgs }:
let
# Try to guess system ourselves
# system = builtins.currentSystem;
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
buck_down = pkgs.stdenv.mkDerivation {
pname = "buck_down";
version = "1.0";
buildInputs = [ pkgs.git ];
# Skip unpackPhase since there's no source to unpack
unpackPhase = "true";
installPhase = ''
mkdir -p $out/bin
echo '#!/bin/sh' > $out/bin/buck_down
# echo 'git checkout HEAD -- "$(git rev-parse --show-toplevel)"' >> $out/bin/buck_down
# Turn on the smudge and clean filters
echo 'git config --local filter.gcs-lfs.smudge ".githooks/gcs_smudge.sh %f"' >> $out/bin/buck_down
echo 'git config --local filter.gcs-lfs.clean ".githooks/clean-filter.sh %f"' >> $out/bin/buck_down
echo 'git config --local filter.gcs-lfs.required true' >> $out/bin/buck_down
# echo 'git checkout HEAD -- "$(git rev-parse --show-toplevel)"' >> $out/bin/buck_down
echo 'git rm --cached -r .' >> $out/bin/buck_down
echo 'git checkout HEAD -- .' >> $out/bin/buck_down
chmod +x $out/bin/buck_down
'';
};
fupp = pkgs.stdenv.mkDerivation {
pname = "fupp";
version = "1.0";
buildInputs = [ pkgs.git ];
# Skip unpackPhase since there's no source to unpack
unpackPhase = "true";
installPhase = ''
mkdir -p $out/bin
echo '#!/bin/sh' > $out/bin/fupp
# Turn on the smudge and clean filters
echo 'git config --local filter.gcs-lfs.smudge ".githooks/gcs_smudge.sh %f"' >> $out/bin/fupp
echo 'git config --local filter.gcs-lfs.clean ".githooks/clean-filter.sh %f"' >> $out/bin/fupp
echo 'git config --local filter.gcs-lfs.required true' >> $out/bin/fupp
chmod +x $out/bin/fupp
'';
};
fdown = pkgs.stdenv.mkDerivation {
pname = "fdown";
version = "1.0";
buildInputs = [ pkgs.git ];
# Skip unpackPhase since there's no source to unpack
unpackPhase = "true";
installPhase = ''
mkdir -p $out/bin
echo '#!/bin/sh' > $out/bin/fdown
# echo 'git checkout HEAD -- "$(git rev-parse --show-toplevel)"' >> $out/bin/fdown
# Turn of the smudge and clean filters
echo 'git config --local filter.gcs-lfs.smudge "cat"' >> $out/bin/fdown
echo 'git config --local filter.gcs-lfs.clean "cat"' >> $out/bin/fdown
echo 'git config --local filter.gcs-lfs.required false' >> $out/bin/fdown
chmod +x $out/bin/fdown
'';
};
in {
devShell.${system} = pkgs.mkShell {
buildInputs = with pkgs; [
python310
git
lazygit
poetry
rsync
zsh
neo4j
xxd
fdown
google-cloud-sdk
fupp
buck_down
];
# Now we add zsh as the shell
shell = pkgs.zsh;
shellHook = ''
echo "Welcome to the ITL remote workstation"
# Create some aliases to my scripts
export IN_FLAKE=1
export SHELL=${nixpkgs.legacyPackages.x86_64-linux.zsh}/bin/zsh
export RPROMPT="%F{cyan}( Poetry)%f"
# Set out the hooks for blob versioning
#find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
GIT_CONFIG_FILE="$PWD/.git/config"
if [ -f "$GIT_CONFIG_FILE" ]; then
if ! grep -q "\[filter \"gcs-lfs\"\]" "$GIT_CONFIG_FILE"; then
# echo "Adding gcs-lfs filter configuration to .git/config"
# git config --local filter.gcs-lfs.clean ".githooks/clean-filter.sh %f"
# chmod +x .githooks/clean-filter.sh
# git config --local filter.gcs-lfs.smudge ".githooks/gcs_smudge.sh %f"
# chmod +x .githooks/gcs_smudge.sh
# git config --local filter.gcs-lfs.required true
# Just set a warning in yellow saying they have to install to install filters or run `buck_down`
echo -e "\033[0;33m::Warning: You have not installed the gcs-lfs filter. Please run 'buck_down' to install it.\033[0m"
else
echo ""
fi
fi
# Set all of them as executables
#chmod +x .git/hooks/*
source ./reproducibility/scripts/initialize_scripts.sh
exec ${nixpkgs.legacyPackages.x86_64-linux.zsh}/bin/zsh
'';
};
};
}