summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock65
-rw-r--r--flake.nix144
2 files changed, 148 insertions, 61 deletions
diff --git a/flake.lock b/flake.lock
index fe81da1..be5d5d4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -22,21 +22,21 @@
"type": "github"
}
},
- "flake-utils": {
+ "flake-parts": {
"inputs": {
- "systems": "systems"
+ "nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
- "lastModified": 1731533236,
- "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "lastModified": 1777988971,
+ "narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
"type": "github"
}
},
@@ -63,11 +63,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1778274207,
- "narHash": "sha256-I4puXmX1iovcCHZlRmztO3vW0mAbbRvq4F8wgIMQ1MM=",
+ "lastModified": 1778580735,
+ "narHash": "sha256-t+8AVV8ExvOmslz2sLIgw/hJBKlyl65rJvxjvvjHgpE=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "b3da656039dc7a6240f27b2ef8cc6a3ef3bccae7",
+ "rev": "48d91f2c0ce7b9e589f967d4f685153dd765dcdd",
"type": "github"
},
"original": {
@@ -77,11 +77,27 @@
"type": "github"
}
},
+ "nixpkgs-lib": {
+ "locked": {
+ "lastModified": 1777168982,
+ "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
+ "owner": "nix-community",
+ "repo": "nixpkgs.lib",
+ "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixpkgs.lib",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
- "flake-utils": "flake-utils",
+ "flake-parts": "flake-parts",
"naersk": "naersk",
- "nixpkgs": "nixpkgs"
+ "nixpkgs": "nixpkgs",
+ "treefmt-nix": "treefmt-nix"
}
},
"rust-analyzer-src": {
@@ -101,18 +117,23 @@
"type": "github"
}
},
- "systems": {
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
"locked": {
- "lastModified": 1681028828,
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
- "owner": "nix-systems",
- "repo": "default",
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "lastModified": 1775636079,
+ "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba",
"type": "github"
},
"original": {
- "owner": "nix-systems",
- "repo": "default",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
"type": "github"
}
}
diff --git a/flake.nix b/flake.nix
index ca8a0ad..4583da1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,52 +1,118 @@
{
inputs = {
- flake-utils.url = "github:numtide/flake-utils";
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ flake-parts.url = "github:hercules-ci/flake-parts";
};
-
outputs =
- {
- flake-utils,
- naersk,
- nixpkgs,
- ...
- }:
- flake-utils.lib.eachDefaultSystem (
- system:
- let
- pkgs = (import nixpkgs) { inherit system; };
-
- naersk' = pkgs.callPackage naersk { };
-
- in
+ inputs@{ flake-parts, ... }:
+ flake-parts.lib.mkFlake { inherit inputs; } (
+ top@{ config, ... }:
{
- # For `nix build` & `nix run`:
- packages.default = naersk'.buildPackage {
- src = ./.;
- nativeBuildInputs = with pkgs; [
- cmake
- flac
- sqlite
- ];
- };
+ imports = [ inputs.treefmt-nix.flakeModule ];
+ systems = [
+ "aarch64-darwin"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "x86_64-linux"
+ ];
+ perSystem =
+ { pkgs, ... }:
+ let
+ naersk' = pkgs.callPackage inputs.naersk { };
+ nativeBuildInputs' = with pkgs; [
+ cargo
+ cmake
+ flac
+ rustc
+ sqlite
+ ];
+ in
+ {
+ packages.default = naersk'.buildPackage {
+ src = ./.;
+ nativeBuildInputs = nativeBuildInputs';
+ };
- # For `nix develop`:
- devShell = pkgs.mkShell {
- nativeBuildInputs = with pkgs; [
- cargo
- rustc
- ];
- packages = with pkgs; [
- nixd
- nixfmt
- rust-analyzer
- clippy
- ];
- };
+ devShells.default = pkgs.mkShell {
+ nativeBuildInputs = nativeBuildInputs';
+ packages = with pkgs; [
+ nixd
+ nixfmt
+ rust-analyzer
+ rustfmt
+ clippy
+ ];
+ };
+
+ treefmt = {
+ projectRootFile = "flake.nix";
+ programs = {
+ nixfmt.enable = true;
+ rustfmt.enable = true;
+ taplo.enable = true;
+ };
+ };
+ };
}
);
}
+
+# outputs =
+# {
+# self,
+# flake-utils,
+# naersk,
+# nixpkgs,
+# treefmt-nix,
+# ...
+# }:
+# flake-utils.lib.eachDefaultSystem (
+# system:
+# let
+# pkgs = (import nixpkgs) { inherit system; };
+
+# naersk' = pkgs.callPackage naersk { };
+
+# treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
+
+# in
+# {
+# # For `nix build` & `nix run`:
+# packages.default = naersk'.buildPackage {
+# src = ./.;
+# nativeBuildInputs = with pkgs; [
+# cmake
+# flac
+# sqlite
+# ];
+# };
+
+# # For `nix develop`:
+# devShells.${system}.default = pkgs.mkShell {
+# nativeBuildInputs = with pkgs; [
+# cargo
+# rustc
+# ];
+# packages = with pkgs; [
+# nixd
+# nixfmt
+# rust-analyzer
+# rustfmt
+# clippy
+# ];
+# };
+# formatter = treefmtEval.config.build.wrapper;
+# checks = {
+# formatting = treefmtEval.config.build.check self;
+# };
+# }
+# );
+# }