From 5625937162ed6034be13567cc21108812d56cf6b Mon Sep 17 00:00:00 2001 From: Kayla Firestack Date: Thu, 14 Oct 2021 10:19:36 -0400 Subject: [PATCH] add nix flake with checks, overlay, and default package --- flake.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..2c9c15b9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "filter": { + "locked": { + "lastModified": 1620202920, + "narHash": "sha256-BOkm3eKT45Dk4NNxJT0xL9NnyYeZcF+t79zPnJkggac=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "3c9e33ed627e009428197b07216613206f06ed80", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1633351077, + "narHash": "sha256-z38JG4Bb0GtM1aF1pANVdp1dniMP23Yb3HnRoJRy2uU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "14aef06d9b3ad1d07626bdbb16083b83f92dc6c1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "filter": "filter", + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..36dda0ec --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + description = "Userspace tools for bcachefs"; + + # Nixpkgs / NixOS version to use. + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + inputs.utils.url = "github:numtide/flake-utils"; + inputs.filter.url = "github:numtide/nix-filter"; + + outputs = { self, nixpkgs, utils, filter, ... }@inputs: + let + # System types to support. + supportedSystems = [ "x86_64-linux" ]; + in + { + version = "${builtins.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}"; + + overlay = import ./nix/overlay.nix inputs; + } + // utils.lib.eachSystem supportedSystems (system: + let pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + }; + in rec { + + # A Nixpkgs overlay. + + # Provide some binary packages for selected system types. + defaultPackage = pkgs.bcachefs.tools; + packages = { + inherit (pkgs.bcachefs) + tools + toolsValgrind + toolsDebug + kernel; + + musl-tools = pkgs.pkgsMusl.bcachefs.tools; + musl-mount = pkgs.pkgsMusl.bcachefs.mount; + }; + + checks = { + kernelSrc = packages.kernel.src; + inherit (packages) + toolsValgrind; + }; + + devShell = devShells.tools; + devShells.tools = pkgs.bcachefs.tools.override { inShell = true; }; + }); +}