Skip to content

Commit

Permalink
chore(nix): add Nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Livshin authored and mmstick committed May 1, 2023
1 parent 5769ec2 commit 47ecd0a
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
48 changes: 48 additions & 0 deletions flake.lock

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

71 changes: 71 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
};
outputs = inputs @ {
self,
nixpkgs,
parts,
...
}: let
inherit (builtins) attrValues;
in parts.lib.mkFlake { inherit inputs; } {
systems = ["x86_64-linux" "x86-linux" "aarch64-linux"];

perSystem = { pkgs, system, ... }: {
packages.system76-scheduler = pkgs.rustPlatform.buildRustPackage {
name = "system76-scheduler";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
# Allow dependencies to be fetched from git and avoid having to set the outputHashes manually
allowBuiltinFetchGit = true;
};

nativeBuildInputs = attrValues {
inherit (pkgs)
pkg-config
llvm
clang
;
};
buildInputs = attrValues {
inherit (pkgs)
dbus
pipewire
;
};

LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
EXECSNOOP_PATH = "${pkgs.bcc}/bin/execsnoop";

# tests don't build
doCheck = false;

postInstall = ''
mkdir -p $out/data
install -D -m 0644 data/com.system76.Scheduler.conf $out/etc/dbus-1/system.d/com.system76.Scheduler.conf
install -D -m 0644 data/*.kdl $out/data/
'';
};

packages.default = self.outputs.packages.${system}.system76-scheduler;

devShells.default = self.packages.${system}.default.overrideAttrs (super: {
nativeBuildInputs = super.nativeBuildInputs
++ (attrValues {
inherit (pkgs)
cargo-edit
clippy
rustfmt
;
});
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
});
};
};
}

0 comments on commit 47ecd0a

Please sign in to comment.