Skip to content

Commit

Permalink
swim: init at 0.10.0 (#344979)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbsds committed Sep 29, 2024
2 parents d71c24c + 01f85c1 commit 72c1fb5
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkgs/by-name/sp/spade/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
rustPlatform,
fetchFromGitLab,
stdenv,
_experimental-update-script-combinators,
nix-update-script,
nix-update,
writeScript,
git,
python312,
swim,
}:

rustPlatform.buildRustPackage rec {
Expand All @@ -29,21 +32,32 @@ rustPlatform.buildRustPackage rec {
};
};

# rust + gitlab is a rare combo
passthru.updateScript = [
# TODO: somehow respect https://nixos.org/manual/nixpkgs/stable/#var-passthru-updateScript-commit
passthru.updateScript = _experimental-update-script-combinators.sequence [
# rust + gitlab + fetchgit is a rare combo
(writeScript "update-spade" ''
VERSION="$(
${lib.getExe git} ls-remote --tags --sort -version:refname ${lib.escapeShellArg src.gitRepoUrl} \
| cut -f2 | grep ^refs/tags/v | cut -d/ -f3- | cut -c2- \
| sort --version-sort --reverse | head -n1
)"
exec ${lib.getExe nix-update} --version "$VERSION" "$@"
exec ${lib.getExe nix-update} spade --version "$VERSION" "$@" --commit
'')
(nix-update-script {
extraArgs = [
"swim"
"--commit"
];
})
];

buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ python312 ];
env.NIX_CFLAGS_LINK = lib.optionalString stdenv.hostPlatform.isDarwin "-L${python312}/lib/python3.12/config-3.12-darwin -lpython3.12";

passthru.tests = {
inherit swim;
};

meta = with lib; {
description = "Better hardware description language";
homepage = "https://gitlab.com/spade-lang/spade";
Expand Down
69 changes: 69 additions & 0 deletions pkgs/by-name/sw/swim/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
lib,
rustPlatform,
fetchFromGitLab,
pkg-config,
openssl,
spade,
stdenv,
darwin,
git,
}:

rustPlatform.buildRustPackage rec {
pname = "swim";
version = "0.10.0";

src = fetchFromGitLab {
owner = "spade-lang";
repo = "swim";
rev = "v${version}";
hash = "sha256-Yuq1eYjxNnmrydzPyx+UWJJlZnC9sIEP3ZEleKmkzIM=";
};

cargoHash = "sha256-3WcMXvxlY0I7HnR+GTxHPAN+1HQsQLymjGFMM6q18xQ=";

preConfigure = ''
# de-vendor spade git submodule
test "$version" = "${spade.version}" || {
>&2 echo ERROR: version mismatch between spade and swim!
false
}
ln -s ${spade.src} runt/spade
'';

nativeBuildInputs = [ pkg-config ];

buildInputs =
[
openssl
]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];

nativeCheckInputs = [ git ];

checkFlags = [
# tries to clone https://gitlab.com/spade-lang/swim-templates
"--skip=init::tests::git_init_then_swim_init_works"
"--skip=init::tests::init_board_correctly_sets_project_name"
"--skip=init::tests::init_board_creates_required_files"
"--skip=plugin::test::deny_changes_to_plugins::edits_are_denied"
"--skip=plugin::test::deny_changes_to_plugins::restores_work"
];

passthru = {
inherit (spade) updateScript;
};

meta = {
description = "Build tool for spade";
homepage = "https://gitlab.com/spade-lang/swim";
changelog = "https://gitlab.com/spade-lang/swim/-/blob/${src.rev}/CHANGELOG.md";
license = lib.licenses.eupl12;
maintainers = with lib.maintainers; [ pbsds ];
mainProgram = "swim";
};
}

0 comments on commit 72c1fb5

Please sign in to comment.