Skip to content

Commit

Permalink
build with nix
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Aug 3, 2024
1 parent 029be21 commit 0bb3df6
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 66 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ clap = { version = "4", features = ["derive"] }
linked-hash-map = "0.5.6"

[dev-dependencies]
lang_tester = { git = "https://github.com/softdevteam/lang_tester", branch = "master" }
tempdir = "0.3"

18 changes: 18 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ pkgs ? import <nixpkgs> { } }:
let
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage rec {
pname = manifest.name;
version = "manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;

buildInputs = [
pkgs.gcc
pkgs.libiconv
pkgs.libgccjit
pkgs.llvmPackages.llvm
pkgs.llvmPackages.clang
];
}
77 changes: 45 additions & 32 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,51 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs: let
lib = nixpkgs.lib;
systems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
outputs =
{ self
, nixpkgs
, flake-utils
, ...
} @ inputs:
let
lib = nixpkgs.lib;
systems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];

forAllSystems = nixpkgs.lib.genAttrs systems;
forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system});
pkgsFor = lib.genAttrs systems (system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
});
devShellFor = system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
script = import ./shell.nix {inherit pkgs;};
forAllSystems = nixpkgs.lib.genAttrs systems;
forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system});

pkgsFor = lib.genAttrs systems (system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
});

devShellFor = system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
script = import ./shell.nix { inherit pkgs; };
in
script;
in
script;
in {
formatter =
forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
devShell = lib.mapAttrs (system: _: devShellFor system) (lib.genAttrs systems {});
};
{
# Nix script formatter
formatter =
forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);

# Development environment
devShell = lib.mapAttrs (system: _: devShellFor system) (lib.genAttrs systems { });

# Output package
packages = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./. { };
});
};
}
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> { } }:

let
# Extract the lib folder from a package
Expand Down
31 changes: 0 additions & 31 deletions tests/run_tests.rs

This file was deleted.

0 comments on commit 0bb3df6

Please sign in to comment.