manage development environment with nix and direnv

This commit is contained in:
guochao 2023-10-14 20:44:19 +08:00
parent cac896ff1d
commit fb6eaf247a
Signed by: guochao
GPG Key ID: 79F7306D2AA32FC3
4 changed files with 59 additions and 0 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
.vscode
.idea
.direnv
vendor
bin

27
flake.lock generated Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1697009197,
"narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

29
flake.nix Normal file
View File

@ -0,0 +1,29 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { nixpkgs, ... }: {
packages = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system:
let pkgs = import nixpkgs { inherit system; }; in {
default = pkgs.buildGoModule {
pname = "demo-signaling-server";
version = "0.0.1";
src = ./.;
vendorHash = "sha256-IUPGl5vHLyzbTVYsCLu4lIWoyq0h96deQ7q/nnVkPjc=";
};
});
devShells = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system:
let pkgs = import nixpkgs { inherit system; }; in {
default = pkgs.mkShell {
packages = with pkgs; [
go
gopls
golangci-lint
];
};
});
};
}