-
Notifications
You must be signed in to change notification settings - Fork 9
nix: init #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jhvst
wants to merge
17
commits into
FStarLang:main
Choose a base branch
from
jhvst:jhvst/nix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
nix: init #264
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ea5d963
nix: init
jhvst d160c8d
flake/packages: add pulse-dune
jhvst 9dc2fce
flake/packages: add pulse
jhvst 11247d8
flake/packages: add pulse-exe
jhvst d7a5d7e
flake/packages: dynamic upstream ocaml imports
jhvst 3a4cf12
flake,CI: add nix build CI support for pulse
jhvst 0d06220
nix: add Cargo.lock
jhvst f9e6faa
nix: fix pulse-dune build
jhvst 939a35f
nix: allow extra flags to pulse
jhvst 3860478
nix: sort inputs, remove systems input
jhvst e343420
flake: bump fstar and pulse revision
jhvst 690cddf
rust: rm Cargo.lock, enable devenv Rust
jhvst bc780dd
flake: remove unused stuff, nits
jhvst 296b0c0
pulse2rust: init on main
jhvst e326225
flake: rm treefmt-nix
jhvst 09173da
flake: rm devenv, update fstar
jhvst 65e317e
flake: vendor fstar, packages.default -> pulse
jhvst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
use flake |
This file contains hidden or 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,17 @@ | ||
# This workflow tests the Nix build of pulse. We run it only for PRs (not | ||
# on every push) and we use Github hosted runners. | ||
|
||
name: Nix Build | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
nix-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
- name: Build | ||
run: nix build -L |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,123 @@ | ||
{ | ||
inputs = { | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
fstar.url = "github:FStarLang/FStar/v2025.03.25"; | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
}; | ||
|
||
outputs = { ... }@inputs: | ||
|
||
inputs.flake-parts.lib.mkFlake { inherit inputs; } { | ||
|
||
systems = inputs.nixpkgs.lib.systems.flakeExposed; | ||
imports = [ ]; | ||
|
||
perSystem = { pkgs, config, system, ... }: { | ||
|
||
packages.pulse = pkgs.stdenv.mkDerivation rec { | ||
|
||
pname = "pulse"; | ||
version = "9a03472d2c366bde5f7b0497bf3356dd445ce207"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "FStarLang"; | ||
repo = pname; | ||
rev = "${version}"; | ||
hash = "sha256-YgWxnX+gCVYx+CCIuprDYKewyEaSekqAilB96eyq+fk="; | ||
}; | ||
|
||
inherit (pkgs.fstar) nativeBuildInputs; | ||
buildInputs = pkgs.fstar.buildInputs ++ [ | ||
pkgs.fstar | ||
pkgs.which | ||
]; | ||
PATH = "${pkgs.fstar}/bin:$PATH"; | ||
|
||
enableParallelBuilding = true; | ||
|
||
installPhase = '' | ||
PREFIX=$out make install | ||
''; | ||
|
||
}; | ||
|
||
packages.pulse-exe = pkgs.writeShellScriptBin "pulse.exe" '' | ||
exec ${pkgs.fstar}/bin/fstar.exe "$1" \ | ||
--include ${config.packages.pulse}/lib/pulse \ | ||
--include ${config.packages.pulse}/lib/pulse/checker \ | ||
--include ${config.packages.pulse}/lib/pulse/extraction \ | ||
--include ${config.packages.pulse}/lib/pulse/lib \ | ||
--include ${config.packages.pulse}/lib/pulse/ml \ | ||
--include ${config.packages.pulse}/lib/pulse/syntax_extension \ | ||
--load_cmxs pulse \ | ||
"$@" | ||
''; | ||
|
||
packages.rustast-bindings = pkgs.rustPlatform.buildRustPackage rec { | ||
inherit (config.packages.pulse) version src; | ||
inherit (pkgs.fstar) nativeBuildInputs; | ||
pname = "rustast-bindings"; | ||
sourceRoot = "${src.name}/pulse2rust/src/ocaml"; | ||
cargoLock = { | ||
lockFile = ./pulse2rust/src/ocaml/Cargo.lock; | ||
}; | ||
postPatch = '' | ||
ln -s ${./pulse2rust/src/ocaml/Cargo.lock} Cargo.lock | ||
''; | ||
}; | ||
|
||
packages.extract = pkgs.stdenv.mkDerivation { | ||
pname = "extract"; | ||
inherit (config.packages.pulse) version; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "FStarLang"; | ||
repo = "pulse"; | ||
rev = "42842b823c45f83376b65bc10ffa803ad6f21dc4"; | ||
hash = "sha256-CRlrfiDXoSn9s0tiU4dunsUsUu00jb8U9/QApfu+Qtw="; | ||
}; | ||
sourceRoot = "source/pulse2rust/src"; | ||
buildInputs = [ | ||
pkgs.fstar | ||
pkgs.which | ||
]; | ||
PATH = "${pkgs.fstar}/bin:$PATH"; | ||
|
||
installPhase = '' | ||
mkdir -p $out/ocaml/generated | ||
cp -r ocaml/generated $out/ocaml | ||
''; | ||
}; | ||
|
||
packages.pulse2rust = inputs.fstar.inputs.nixpkgs.legacyPackages.${system}.ocaml-ng.ocamlPackages_4_14.buildDunePackage rec { | ||
inherit (config.packages.pulse) version src; | ||
pname = "main"; | ||
sourceRoot = "${src.name}/pulse2rust/src/ocaml"; | ||
|
||
nativeBuildInputs = pkgs.fstar.nativeBuildInputs ++ [ pkgs.fstar ]; | ||
buildInputs = pkgs.fstar.buildInputs ++ [ pkgs.fstar ]; | ||
|
||
buildPhase = '' | ||
eval $(${pkgs.fstar}/bin/fstar.exe --ocamlenv) | ||
mkdir -p $out/bin | ||
dune build main.exe --build-dir=$out/bin | ||
''; | ||
|
||
postPatch = '' | ||
ln -s ${./pulse2rust/src/dune-project} dune-project | ||
ln -s ${config.packages.rustast-bindings}/lib/librustast_bindings.a librustast_bindings.a | ||
mkdir -p ocaml/generated | ||
cp -r ${config.packages.extract}/ocaml/generated ocaml | ||
''; | ||
|
||
# overwrites the default dune installPhase | ||
installPhase = ''''; | ||
|
||
meta.mainProgram = "default/ocaml/main.exe"; | ||
}; | ||
|
||
packages.fstar = pkgs.fstar; | ||
|
||
packages.default = config.packages.pulse; | ||
|
||
}; | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit here, given that
lib/fstar.include
exists, the only thing needed is--include ${config.packages.pulse}/lib
.(Also F* will try to automatically load plugins when there's is a
#lang-X
directive, so the--load_cmxs
is mostly redundant, but still required for some files currently, so best to keep it.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have to figure out how to get the
lib/fstar.include
to be found. For some reason I could not get the command to work unless the paths are exhaustively and explicitly included.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.. interesting. Then this is fine and we can later try to reduce it, fstar.include is rather new so no worries.