-
Notifications
You must be signed in to change notification settings - Fork 27
/
flake.nix
42 lines (40 loc) · 1.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
# start : bash : nix run .#dev
# 或者 nix shell .#dev --command 'dev-shell'
{
description = "A Nix-flake-based golang development environment .";
inputs = {
#nixpkgs.url = "github:NixOS/nixpkgs/23.11";
#nixpkgs.url = "https://mirrors.ustc.edu.cn/nix-channels/nixpkgs-unstable/nixexprs.tar.xz";
nixpkgs.url = "https://mirrors.ustc.edu.cn/nix-channels/nixos-24.05/nixexprs.tar.xz";
};
outputs = { self , nixpkgs ,... }: let
# system should match the system you are running on
system = "x86_64-linux";
# system = "x86_64-darwin";
in {
packages."${system}".dev = let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
packages = with pkgs; [
go_1_23
gopls
gcc
upx
jetbrains.goland # allowUnfree
nushell
];
in pkgs.runCommand "dev-shell" {
# Dependencies that should exist in the runtime environment
buildInputs = packages;
# Dependencies that should only exist in the build environment
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin/
ln -s ${pkgs.nushell}/bin/nu $out/bin/dev-shell
wrapProgram $out/bin/dev-shell --set GOPROXY https://goproxy.cn,direct
wrapProgram $out/bin/dev-shell --prefix PATH : ${pkgs.lib.makeBinPath packages}
'';
};
}