Skip to content

Commit e8022e0

Browse files
authored
add nix flake (#117)
adds: - a flake that: - has a devshell with the packages: - `cargo` - `rustc` - `git` - can build goboscript from `default.nix` - a vscode settings entry that lists the added flake as the desired nix environment - a gitignore entry for the `nix build` output directory (`./result`) - a `default.nix` file that contains the goboscript package
2 parents 4ade10b + 40ec4e7 commit e8022e0

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/playground
55
node_modules
66
site
7+
/result
78
# Added by goreleaser init:
89
dist/
910
.intentionally-empty-file.o

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"./Cargo.toml",
66
"./Cargo.toml"
77
],
8-
"rust-analyzer.showUnlinkedFileNotification": false
8+
"rust-analyzer.showUnlinkedFileNotification": false,
9+
"nixEnvSelector.nixFile": "${workspaceRoot}/flake.nix"
910
}

default.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ lib, rustPlatform }:
2+
3+
rustPlatform.buildRustPackage {
4+
pname = "goboscript";
5+
version = "3.0.0";
6+
7+
src = ./.;
8+
9+
cargoLock = {
10+
lockFile = ./Cargo.lock;
11+
};
12+
13+
meta = {
14+
description = "Scratch compiler";
15+
homepage = "https://github.com/aspizu/goboscript";
16+
license = lib.licenses.mit;
17+
};
18+
}

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
description = "Scratch compiler";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
10+
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let
11+
pkgs = nixpkgs.legacyPackages.${system};
12+
in rec {
13+
packages.goboscript = pkgs.callPackage ./default.nix { };
14+
15+
legacyPackages = packages;
16+
17+
defaultPackage = packages.goboscript;
18+
19+
devShell = pkgs.mkShell {
20+
buildInputs = with pkgs; [ cargo rustc git ];
21+
};
22+
});
23+
}

0 commit comments

Comments
 (0)