-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from SnO2WMaN/nix-flake
Add Nix support for reproducible build and develop
- Loading branch information
Showing
11 changed files
with
292 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
flake.lock linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
( | ||
import | ||
( | ||
fetchTarball | ||
(with (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat.locked; { | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
sha256 = narHash; | ||
}) | ||
) | ||
{src = ./.;} | ||
) | ||
.defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
description = "Nix Flake for Erg Programming Language"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
|
||
# develop | ||
devshell.url = "github:numtide/devshell"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
flake-compat = { | ||
url = "github:edolstra/flake-compat"; | ||
flake = false; | ||
}; | ||
}; | ||
outputs = { | ||
self, | ||
nixpkgs, | ||
devshell, | ||
flake-utils, | ||
... | ||
}: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ | ||
devshell.overlay | ||
]; | ||
}; | ||
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml)); | ||
|
||
inherit (pkgs) lib; | ||
in { | ||
packages.erg = pkgs.rustPlatform.buildRustPackage { | ||
inherit (cargoToml.package) name version; | ||
src = builtins.path { | ||
path = ./.; | ||
filter = name: type: | ||
(name == toString ./Cargo.toml) | ||
|| (name == toString ./Cargo.lock) | ||
|| (lib.hasPrefix (toString ./compiler) name) | ||
|| (lib.hasPrefix (toString ./src) name); | ||
}; | ||
cargoLock.lockFile = ./Cargo.lock; | ||
}; | ||
packages.default = self.packages.${system}.erg; | ||
|
||
devShells.default = pkgs.devshell.mkShell { | ||
packages = with pkgs; [ | ||
gcc | ||
rustc | ||
cargo | ||
# Dev | ||
python3 | ||
treefmt # cli to run all formatters | ||
alejandra # Nix formatter | ||
# rustfmt # Rust Formatter | ||
# taplo-cli # TOML formatter | ||
]; | ||
}; | ||
|
||
checks = { | ||
erg = self.packages.${system}.erg; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
( | ||
import | ||
( | ||
fetchTarball | ||
(with (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat.locked; { | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
sha256 = narHash; | ||
}) | ||
) | ||
{src = ./.;} | ||
) | ||
.shellNix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[formatter.alejandra] | ||
command = "alejandra" | ||
includes = ["*.nix"] | ||
|
||
# [formatter.taplo] | ||
# command = "taplo" | ||
# options = ["format"] | ||
# includes = ["*.toml"] | ||
|
||
# [formatter.rustfmt] | ||
# command = "rustfmt" | ||
# includes = ["*.rs"] |