tangled
alpha
login
or
join now
karitham.dev
/
dotfiles
0
fork
atom
nix all the things
0
fork
atom
overview
issues
pulls
pipelines
pkgs/topiary-nu: rewrite, simplify
karitham.dev
2 months ago
56b7ff1e
f861bfdb
+40
-102
4 changed files
expand all
collapse all
unified
split
flake.lock
flake.nix
modules
default.nix
pkgs
topiary-nu.nix
-34
flake.lock
···
552
552
"sops-nix": "sops-nix",
553
553
"ssh-keys": "ssh-keys",
554
554
"starship-jj": "starship-jj",
555
555
-
"topiary-nushell": "topiary-nushell",
556
556
-
"tree-sitter-nu": "tree-sitter-nu",
557
555
"zjstatus": "zjstatus"
558
556
}
559
557
},
···
732
730
"original": {
733
731
"owner": "nix-systems",
734
732
"repo": "default",
735
735
-
"type": "github"
736
736
-
}
737
737
-
},
738
738
-
"topiary-nushell": {
739
739
-
"flake": false,
740
740
-
"locked": {
741
741
-
"lastModified": 1764637932,
742
742
-
"narHash": "sha256-2DOqs/zIDIS/Fdy36txfncwpetrXxXY6RcQ0v+09cIc=",
743
743
-
"owner": "blindFS",
744
744
-
"repo": "topiary-nushell",
745
745
-
"rev": "71460ddb383a83286437ea951f946131ccca7e3f",
746
746
-
"type": "github"
747
747
-
},
748
748
-
"original": {
749
749
-
"owner": "blindFS",
750
750
-
"repo": "topiary-nushell",
751
751
-
"type": "github"
752
752
-
}
753
753
-
},
754
754
-
"tree-sitter-nu": {
755
755
-
"flake": false,
756
756
-
"locked": {
757
757
-
"lastModified": 1765660476,
758
758
-
"narHash": "sha256-h02kb3VxSK/fxQENtj2yaRmAQ5I8rt5s5R8VrWOQWeo=",
759
759
-
"owner": "nushell",
760
760
-
"repo": "tree-sitter-nu",
761
761
-
"rev": "4c149627cc592560f77ead1c384e27ec85926407",
762
762
-
"type": "github"
763
763
-
},
764
764
-
"original": {
765
765
-
"owner": "nushell",
766
766
-
"repo": "tree-sitter-nu",
767
733
"type": "github"
768
734
}
769
735
},
-8
flake.nix
···
49
49
url = "github:karitham/knixpkgs";
50
50
inputs.nixpkgs.follows = "nixpkgs";
51
51
};
52
52
-
tree-sitter-nu = {
53
53
-
url = "github:nushell/tree-sitter-nu";
54
54
-
flake = false;
55
55
-
};
56
56
-
topiary-nushell = {
57
57
-
url = "github:blindFS/topiary-nushell";
58
58
-
flake = false;
59
59
-
};
60
52
sops-nix = {
61
53
url = "github:Mic92/sops-nix";
62
54
inputs.nixpkgs.follows = "nixpkgs";
+1
-1
modules/default.nix
···
20
20
packages = {
21
21
pokego = pkgs.callPackage ./pkgs/pokego.nix { };
22
22
http-nu = pkgs.callPackage ./pkgs/http-nu.nix { };
23
23
-
topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix { inherit (inputs) tree-sitter-nu topiary-nushell; };
23
23
+
topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix { };
24
24
atproto-lastfm-importer = pkgs.callPackage ./pkgs/atproto-lastfm-importer.nix { };
25
25
multi-scrobbler = pkgs.callPackage ./pkgs/multi-scrobbler.nix { };
26
26
+39
-59
modules/pkgs/topiary-nu.nix
···
1
1
{
2
2
lib,
3
3
-
stdenv,
4
4
-
tree-sitter,
3
3
+
writeShellApplication,
5
4
topiary,
6
6
-
makeWrapper,
7
7
-
runCommand,
8
8
-
nodejs,
9
9
-
tree-sitter-nu,
10
10
-
topiary-nushell,
5
5
+
nushell,
6
6
+
tree-sitter-grammars,
7
7
+
writeText,
8
8
+
linkFarm,
9
9
+
pkgs, # otherwise lint issue because `fetchurl` is a builtin
11
10
}:
12
11
let
13
13
-
treeSitterNu = stdenv.mkDerivation {
14
14
-
name = "tree-sitter-nu";
15
15
-
src = tree-sitter-nu;
16
16
-
buildInputs = [
17
17
-
tree-sitter
18
18
-
nodejs
19
19
-
];
20
20
-
buildPhase = ''
21
21
-
tree-sitter generate
22
22
-
gcc -o parser.so -Isrc src/parser.c src/scanner.c -shared -fPIC -O2
23
23
-
'';
24
24
-
installPhase = ''
25
25
-
mkdir -p $out
26
26
-
cp parser.so $out/parser
27
27
-
'';
28
28
-
};
29
29
-
30
30
-
configDir = stdenv.mkDerivation {
31
31
-
name = "topiary-nu-config";
32
32
-
src = topiary-nushell;
33
33
-
34
34
-
buildPhase = ''
35
35
-
mkdir -p $out
36
36
-
cat <<EOF > $out/languages.ncl
37
37
-
{
38
38
-
languages = {
39
39
-
nu = {
40
40
-
extensions = ["nu"],
41
41
-
grammar.source.path = "${treeSitterNu}/parser"
42
42
-
},
43
43
-
},
44
44
-
}
45
45
-
EOF
46
46
-
'';
47
47
-
48
48
-
installPhase = ''
49
49
-
cp -r $src/languages $out
50
50
-
'';
12
12
+
langDir = linkFarm "topiary-nu-languages" [
13
13
+
{
14
14
+
name = "nu.scm";
15
15
+
path = pkgs.fetchurl {
16
16
+
url = "https://raw.githubusercontent.com/blindFS/topiary-nushell/main/languages/nu.scm";
17
17
+
hash = "sha256-2o7oIFkxuy8u8HNkiEzNnoKekmwaxClCWQnQg3rgVeU=";
18
18
+
};
19
19
+
}
20
20
+
];
21
21
+
configFile = writeText "languages.json" (
22
22
+
builtins.toJSON {
23
23
+
languages = {
24
24
+
nu = {
25
25
+
extensions = [ "nu" ];
26
26
+
grammar.source.path = "${tree-sitter-grammars.tree-sitter-nu}/parser";
27
27
+
};
28
28
+
};
29
29
+
}
30
30
+
);
31
31
+
in
32
32
+
writeShellApplication {
33
33
+
name = "topiary-nu";
34
34
+
runtimeInputs = [
35
35
+
nushell
36
36
+
topiary
37
37
+
];
38
38
+
runtimeEnv = {
39
39
+
TOPIARY_CONFIG_FILE = configFile;
40
40
+
TOPIARY_LANGUAGE_DIR = langDir;
51
41
};
52
52
-
in
53
53
-
runCommand "topiary-nu"
54
54
-
{
55
55
-
buildInputs = [ makeWrapper ];
56
56
-
meta = {
57
57
-
mainProgram = "topiary-nu";
58
58
-
};
59
59
-
}
60
60
-
''
61
61
-
mkdir -p $out/bin
62
62
-
makeWrapper ${lib.getExe topiary} $out/bin/topiary-nu \
63
63
-
--set TOPIARY_LANGUAGE_DIR "${configDir}/languages" \
64
64
-
--set TOPIARY_CONFIG_FILE "${configDir}/languages.ncl"
65
65
-
''
42
42
+
text = ''
43
43
+
${lib.getExe topiary} "$@"
44
44
+
'';
45
45
+
}