summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2023-10-29 10:12:22 +0100
committerGitHub <noreply@github.com>2023-10-29 10:12:22 +0100
commit102a57056b41e3965a1acf528f17dd0c5e5ea673 (patch)
tree0ac39a33fa273577d7df4a9f814c5940904038c3
parent29130a26f83f28ae37be1ff4f57877e765d27285 (diff)
Prevent Nix warning when using `lib.getExe` (#2507)
1. Remove unecessary inputs 2. Use `flake-parts` module `easyOverlay` 3. Add default Nix formatter 4. Make `systems` attr overridable
-rw-r--r--flake.lock138
-rw-r--r--flake.nix164
2 files changed, 107 insertions, 195 deletions
diff --git a/flake.lock b/flake.lock
index c1296960..3cfbc938 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,19 +2,16 @@
"nodes": {
"crane": {
"inputs": {
- "flake-compat": "flake-compat",
- "flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
- ],
- "rust-overlay": "rust-overlay"
+ ]
},
"locked": {
- "lastModified": 1693787605,
- "narHash": "sha256-rwq5U8dy+a9JFny/73L0SJu1GfWwATMPMTp7D+mjHy8=",
+ "lastModified": 1698166613,
+ "narHash": "sha256-y4rdN4flxRiROqNi1waMYIZj/Fs7L2OrszFk/1ry9vU=",
"owner": "ipetkov",
"repo": "crane",
- "rev": "8b4f7a4dab2120cf41e7957a28a853f45016bd9d",
+ "rev": "b7db46f0f1751f7b1d1911f6be7daf568ad5bc65",
"type": "github"
},
"original": {
@@ -23,89 +20,52 @@
"type": "github"
}
},
- "flake-compat": {
- "flake": false,
- "locked": {
- "lastModified": 1673956053,
- "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
- "owner": "edolstra",
- "repo": "flake-compat",
- "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
- "type": "github"
- },
- "original": {
- "owner": "edolstra",
- "repo": "flake-compat",
- "type": "github"
- }
- },
"flake-parts": {
"inputs": {
- "nixpkgs-lib": [
- "nixpkgs"
- ]
+ "nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
- "lastModified": 1693611461,
- "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
+ "lastModified": 1696343447,
+ "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
- "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
+ "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
"type": "github"
},
"original": {
- "owner": "hercules-ci",
- "repo": "flake-parts",
- "type": "github"
+ "id": "flake-parts",
+ "type": "indirect"
}
},
- "flake-utils": {
- "inputs": {
- "systems": "systems"
- },
+ "nixpkgs": {
"locked": {
- "lastModified": 1692799911,
- "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
+ "lastModified": 1698318101,
+ "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
"type": "github"
}
},
- "flake-utils_2": {
- "inputs": {
- "systems": "systems_2"
- },
+ "nixpkgs-lib": {
"locked": {
- "lastModified": 1692799911,
- "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
- "type": "github"
- },
- "original": {
- "owner": "numtide",
- "repo": "flake-utils",
- "type": "github"
- }
- },
- "nixpkgs": {
- "locked": {
- "lastModified": 1693985761,
- "narHash": "sha256-K5b+7j7Tt3+AqbWkcw+wMeqOAWyCD1MH26FPZyWXpdo=",
- "owner": "nixos",
+ "dir": "lib",
+ "lastModified": 1696019113,
+ "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
+ "owner": "NixOS",
"repo": "nixpkgs",
- "rev": "0bffda19b8af722f8069d09d8b6a24594c80b352",
+ "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
"type": "github"
},
"original": {
- "owner": "nixos",
+ "dir": "lib",
+ "owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
@@ -115,33 +75,8 @@
"inputs": {
"crane": "crane",
"flake-parts": "flake-parts",
- "flake-utils": "flake-utils_2",
- "nixpkgs": "nixpkgs"
- }
- },
- "rust-overlay": {
- "inputs": {
- "flake-utils": [
- "crane",
- "flake-utils"
- ],
- "nixpkgs": [
- "crane",
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1693707092,
- "narHash": "sha256-HR1EnynBSPqbt+04/yxxqsG1E3n6uXrOl7SPco/UnYo=",
- "owner": "oxalica",
- "repo": "rust-overlay",
- "rev": "98ccb73e6eefc481da6039ee57ad8818d1ca8d56",
- "type": "github"
- },
- "original": {
- "owner": "oxalica",
- "repo": "rust-overlay",
- "type": "github"
+ "nixpkgs": "nixpkgs",
+ "systems": "systems"
}
},
"systems": {
@@ -158,21 +93,6 @@
"repo": "default",
"type": "github"
}
- },
- "systems_2": {
- "locked": {
- "lastModified": 1681028828,
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
- "owner": "nix-systems",
- "repo": "default",
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
- "type": "github"
- },
- "original": {
- "owner": "nix-systems",
- "repo": "default",
- "type": "github"
- }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index 7430f962..f3476e52 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,64 +2,65 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
- flake-parts = {
- url = "github:hercules-ci/flake-parts";
- inputs.nixpkgs-lib.follows = "nixpkgs";
- };
-
- flake-utils.url = "github:numtide/flake-utils";
-
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
- };
-
- outputs = inputs@{ flake-parts, flake-utils, crane, nixpkgs, ... }:
- let
- # Generate the typst package for the given nixpkgs instance.
- packageFor = pkgs:
- let
- inherit (nixpkgs.lib)
- importTOML
- optionals
- sourceByRegex
- ;
- Cargo-toml = importTOML ./Cargo.toml;
-
- pname = "typst";
- version = Cargo-toml.workspace.package.version;
-
- # Crane-based Nix flake configuration.
- # Based on https://github.com/ipetkov/crane/blob/master/examples/trunk-workspace/flake.nix
-
- craneLib = crane.mkLib pkgs;
-
- # Typst files to include in the derivation.
- # Here we include Rust files, assets and tests.
- src = sourceByRegex ./. [
- "(assets|crates|tests)(/.*)?"
- ''Cargo\.(toml|lock)''
- ''build\.rs''
- ];
- # Typst derivation's args, used within crane's derivation generation
- # functions.
- commonCraneArgs = {
- inherit src pname version;
+ systems.url = "github:nix-systems/default";
+ };
- buildInputs = optionals pkgs.stdenv.isDarwin [
- pkgs.darwin.apple_sdk.frameworks.CoreServices
+ outputs = inputs@{ flake-parts, crane, nixpkgs, ... }: flake-parts.lib.mkFlake { inherit inputs; } {
+ systems = import inputs.systems;
+
+ imports = [
+ inputs.flake-parts.flakeModules.easyOverlay
+ ];
+
+ perSystem = { self', pkgs, lib, ... }:
+ let
+ # Generate the typst package for the given nixpkgs instance.
+ packageFor = pkgs:
+ let
+ inherit (lib)
+ importTOML
+ optionals
+ sourceByRegex
+ ;
+ Cargo-toml = importTOML ./Cargo.toml;
+
+ pname = "typst";
+ version = Cargo-toml.workspace.package.version;
+
+ # Crane-based Nix flake configuration.
+ # Based on https://github.com/ipetkov/crane/blob/master/examples/trunk-workspace/flake.nix
+ craneLib = crane.mkLib pkgs;
+
+ # Typst files to include in the derivation.
+ # Here we include Rust files, assets and tests.
+ src = sourceByRegex ./. [
+ "(assets|crates|tests)(/.*)?"
+ ''Cargo\.(toml|lock)''
+ ''build\.rs''
];
- nativeBuildInputs = [ pkgs.installShellFiles ];
- };
+ # Typst derivation's args, used within crane's derivation generation
+ # functions.
+ commonCraneArgs = {
+ inherit src pname version;
+
+ buildInputs = optionals pkgs.stdenv.isDarwin [
+ pkgs.darwin.apple_sdk.frameworks.CoreServices
+ ];
- # Derivation with just the dependencies, so we don't have to keep
- # re-building them.
- cargoArtifacts = craneLib.buildDepsOnly commonCraneArgs;
+ nativeBuildInputs = [ pkgs.installShellFiles ];
+ };
- typst = craneLib.buildPackage (commonCraneArgs // {
+ # Derivation with just the dependencies, so we don't have to keep
+ # re-building them.
+ cargoArtifacts = craneLib.buildDepsOnly commonCraneArgs;
+ in
+ craneLib.buildPackage (commonCraneArgs // {
inherit cargoArtifacts;
postInstall = ''
@@ -70,47 +71,38 @@
'';
GEN_ARTIFACTS = "artifacts";
+
+ meta.mainProgram = "typst";
});
- in
- typst;
- in
- flake-parts.lib.mkFlake { inherit inputs; } {
- systems = [
- "aarch64-darwin"
- "aarch64-linux"
- "x86_64-darwin"
- "x86_64-linux"
- ];
-
- flake = {
- overlays.default = _: prev: {
- typst-dev = packageFor prev;
+
+ typst = packageFor pkgs;
+ in
+ {
+ formatter = pkgs.nixpkgs-fmt;
+
+ packages = {
+ default = typst;
+ typst-dev = self'.packages.default;
};
- };
- perSystem = { pkgs, ... }:
- let
- inherit (pkgs) lib;
- typst = packageFor pkgs;
- in
- {
- packages.default = typst;
-
- apps.default = flake-utils.lib.mkApp {
- drv = typst;
- };
-
- devShells.default = pkgs.mkShell {
- packages = with pkgs; [
- rustc
- cargo
- ];
+ overlayAttrs = builtins.removeAttrs self'.packages [ "default" ];
- buildInputs = lib.optionals pkgs.stdenv.isDarwin [
- pkgs.darwin.apple_sdk.frameworks.CoreServices
- pkgs.libiconv
- ];
- };
+ apps.default = {
+ type = "app";
+ program = lib.getExe typst;
};
- };
+
+ devShells.default = pkgs.mkShell {
+ packages = with pkgs; [
+ rustc
+ cargo
+ ];
+
+ buildInputs = lib.optionals pkgs.stdenv.isDarwin [
+ pkgs.darwin.apple_sdk.frameworks.CoreServices
+ pkgs.libiconv
+ ];
+ };
+ };
+ };
}