Skip to content

Add Nix package #25

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

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nix/** linguist-generated
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ pip install image-tools-stackabletech
pip install git+https://github.com/stackabletech/image-tools.git@main
```

Or via Nix Shell:

```nix
{ lib, pkgs, ... }:
with lib;
let
image-tools = pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "stackabletech";
repo = "image-tools";
rev = "caa4d993bcbb8b884097c89a54ee246f975e2ec6";
hash = "sha256-gjTCroHw4iJhXPW+s3mHBzIH8seIKH1tPb82lUb8+a0="; # comment out to find new hashes when upgrading
} + "/image-tools.nix") {};
in
{
packages = with pkgs; [
image-tools
# ...
];

// ...
}
```

## Release a new version

Update the version in:
Expand Down
8 changes: 8 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ sources ? import ./nix/sources.nix # managed by https://github.com/nmattia/niv
, nixpkgs ? sources.nixpkgs
, pkgs ? import nixpkgs {}
}:

{
image-tools = pkgs.callPackage ./image-tools.nix {};
}
35 changes: 35 additions & 0 deletions image-tools.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ python3, runCommand, lib }:
let
# I wish there was a better way. If the command fails, it is very hard to see
# that the problem is here. Perhaps there is some way to evaluate it in python
# and reference __version__ directly?
version = builtins.readFile (runCommand "image-tools-version" {} ''
PYTHONPATH=${./src} ${python3}/bin/python -c 'import image_tools.version; print(image_tools.version.__version__)' > $out
'');
manifest = (lib.importTOML ./pyproject.toml).project;
in
python3.pkgs.buildPythonApplication {
pname = manifest.name;
# The version is no longer set in pyproject.toml, so we have to jump through
# hoops to extract it from a python script.
# version = manifest.version;
inherit version;

format = "pyproject";

src = builtins.path {
path = ./.;
name = manifest.name;
};

nativeBuildInputs = with python3.pkgs; [
setuptools
];

propagatedBuildInputs = with python3.pkgs; [
jinja2
pyyaml
];
}


14 changes: 14 additions & 0 deletions nix/sources.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

198 changes: 198 additions & 0 deletions nix/sources.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.