Skip to content

Commit 22fc30a

Browse files
committed
add nix flake
1 parent f9d6681 commit 22fc30a

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ The optimization relies on a simple 2-fold logic:
1919
pip install optimal-congress
2020
```
2121

22+
With nix, you can run this application directly (contact [kaesaecracker](https://github.com/kaesaecracker) if this does not work):
23+
```bash
24+
nix run github:top-on/optimal-congress
25+
```
26+
2227
## Available commands
2328

2429
`optimal-congress` provides the following commands:

flake.lock

Lines changed: 141 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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
description = "Flake for optimal-congress";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
6+
poetry2nix = {
7+
url = "github:nix-community/poetry2nix";
8+
inputs.nixpkgs.follows = "nixpkgs";
9+
};
10+
};
11+
12+
outputs =
13+
{
14+
self,
15+
nixpkgs,
16+
poetry2nix,
17+
}:
18+
let
19+
lib = nixpkgs.lib;
20+
forAllSystems = lib.genAttrs [
21+
"x86_64-linux"
22+
"aarch64-linux"
23+
"aarch64-darwin"
24+
"x86_64-darwin"
25+
];
26+
poetryConfig = {
27+
projectDir = ./.;
28+
# when compiling locally, this flake does not work because transitive rust dependencies are not version pinned
29+
preferWheels = true;
30+
};
31+
in
32+
{
33+
apps = forAllSystems (
34+
system:
35+
let
36+
pkgs = nixpkgs.legacyPackages."${system}";
37+
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
38+
myPythonApp = mkPoetryApplication poetryConfig;
39+
in
40+
rec {
41+
optimal-congress = {
42+
type = "app";
43+
program = "${myPythonApp}/bin/optimal-congress";
44+
};
45+
46+
default = optimal-congress;
47+
}
48+
);
49+
50+
formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixfmt-rfc-style);
51+
};
52+
}

0 commit comments

Comments
 (0)