clean up nix expressions (#469)

This commit is contained in:
moni 2022-08-15 16:56:05 +08:00 committed by GitHub
parent 7a3e2f4448
commit 39eeeff7cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 81 deletions

View file

@ -1,9 +1,13 @@
(import ( (import
(
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball { in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; } sha256 = lock.nodes.flake-compat.locked.narHash;
) { }
)
{
src = ./.; src = ./.;
}).defaultNix }).defaultNix

46
flake.lock generated
View file

@ -8,11 +8,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1635402244, "lastModified": 1654237591,
"narHash": "sha256-4bUSYJDRxAo66UpNkFmEMRIWMdDXBEnq8GB/rG++Y3A=", "narHash": "sha256-+uOzx9fuo3CBHO7aGI+SKxDXpf/7NTOXi0g4UxOdk9k=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "840f96d1f3257d64c04fe949dfc9c0b4795c04c1", "rev": "8dccfbe51a8adea643ec29a4ec516499a5a081c6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -24,11 +24,11 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1627913399, "lastModified": 1650374568,
"narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", "rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -39,11 +39,11 @@
}, },
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1634851050, "lastModified": 1653893745,
"narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -57,11 +57,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1635444951, "lastModified": 1653413650,
"narHash": "sha256-1y3YkERwoYDIZjGow7HLAR8K3C/9VBPCBy8VpftMPsM=", "narHash": "sha256-wojDHjb+eU80MPH+3HQaK0liUy8EgR95rvmCl24i58Y=",
"owner": "nmattia", "owner": "nmattia",
"repo": "naersk", "repo": "naersk",
"rev": "0d2ce479df4633dbeb53a8ea96e5098ed37fbcc6", "rev": "69daaceebe12c070cd5ae69ba38f277bbf033695",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -72,11 +72,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1635481254, "lastModified": 1654126564,
"narHash": "sha256-tyVpgjeNhzCP2bBdIgFOkTtwDJWO/bKp59V5ctfonyg=", "narHash": "sha256-sgDXDKGmUG4h7OPDOHyQggFQ08ZqVzUIPi8351yhugY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f1d9248eddad2369fca6572470670ec45aa85272", "rev": "f1c9c23aad972787f00f175651e4cb0d7c7fd5ea",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -86,11 +86,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1635336330, "lastModified": 1654126564,
"narHash": "sha256-EPrCZTmuOEY1KLjUCu7rXCBxNemggIFJMDdfEqXQKGo=", "narHash": "sha256-sgDXDKGmUG4h7OPDOHyQggFQ08ZqVzUIPi8351yhugY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "51acb65b302551ac7993b437cc6863fe9fa8ae50", "rev": "f1c9c23aad972787f00f175651e4cb0d7c7fd5ea",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -111,15 +111,15 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1635274542, "lastModified": 1654178556,
"narHash": "sha256-Cew1/WUozM3jalItPuj4cNN8GIFMvCaJ1KXoj6wrHwE=", "narHash": "sha256-LG8J9E/wMBolkWS3VstuvhgQ4jOp3Nk328EXlCYY24U=",
"owner": "rust-analyzer", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "dd43f3f2d13a32199828e758ddf13176df1f17f9", "rev": "88024c7ec2d44a8be8bf05a6580409200cf726fc",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "rust-analyzer", "owner": "rust-lang",
"ref": "nightly", "ref": "nightly",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"type": "github" "type": "github"

View file

@ -1,62 +1,76 @@
{ {
inputs = { inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = { fenix = {
url = "github:nix-community/fenix"; url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
naersk.url = "github:nmattia/naersk"; naersk.url = "github:nmattia/naersk";
}; };
outputs = { self, flake-utils, fenix, nixpkgs, naersk, flake-compat, ... }: outputs = { self, flake-utils, fenix, nixpkgs, naersk, flake-compat, ... }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (system:
let let
# Add rust nightly to pkgs pkgs = import nixpkgs { inherit system; };
pkgs = nixpkgs.legacyPackages.${system} // { inherit (fenix.packages.${system}.latest) cargo rustc rust-src clippy-preview rustfmt-preview; }; toolchain = fenix.packages.${system}.latest;
naersk-lib = (naersk.lib."${system}".override { naersk-lib = (naersk.lib."${system}".override {
cargo = pkgs.cargo; inherit (toolchain) cargo rustc;
rustc = pkgs.rustc;
}); });
eww = { wayland ? false }: mkEww = { wayland ? false }:
naersk-lib.buildPackage { naersk-lib.buildPackage {
pname = "eww"; pname = "eww";
buildInputs = pkgs.lib.optional wayland pkgs.gtk-layer-shell; src = builtins.path { name = "eww"; path = ./.; };
nativeBuildInputs = with pkgs; [ pkg-config gtk3 ]; nativeBuildInputs = with pkgs; [ pkg-config gtk3 ];
cargoBuildOptions = opts: opts ++ pkgs.lib.optionals wayland [ "--no-default-features" "--features=wayland" ]; buildInputs = pkgs.lib.optional wayland pkgs.gtk-layer-shell;
root = ./.;
cargoBuildOptions = opts: opts ++ pkgs.lib.optionals wayland [
"--no-default-features"
"--features=wayland"
];
};
in
{
apps = rec {
default = eww;
eww = flake-utils.lib.mkApp { drv = self.packages.${system}.eww; };
eww-wayland = flake-utils.lib.mkApp { drv = self.packages.${system}.eww-wayland; };
}; };
in rec { packages = rec {
packages.eww = eww {}; default = eww;
packages.eww-wayland = eww {wayland=true;}; eww = mkEww { };
eww-wayland = mkEww { wayland = true; };
};
defaultPackage = self.packages.${system}.eww; devShells.default = pkgs.mkShell {
packages = builtins.attrValues {
apps.eww = flake-utils.lib.mkApp { drv = packages.eww; }; inherit (toolchain)
apps.eww-wayland = flake-utils.lib.mkApp { drv = packages.eww-wayland; };
defaultApp = apps.eww;
devShell = pkgs.mkShell {
packages = with pkgs; [
rustc
cargo cargo
rustc
rust-src
clippy-preview
rustfmt-preview;
inherit (pkgs)
rust-analyzer rust-analyzer
gcc gcc
gtk3 gtk3
gtk-layer-shell gtk-layer-shell
pkg-config pkg-config
rustfmt-preview
clippy-preview
deno deno
mdbook mdbook;
]; };
RUST_SRC_PATH = "${pkgs.rust-src}/lib/rustlib/src/rust/library";
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
}; };
}); });
} }

View file

@ -1,9 +1,13 @@
(import ( (import
(
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball { in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; } sha256 = lock.nodes.flake-compat.locked.narHash;
) { }
)
{
src = ./.; src = ./.;
}).shellNix }).shellNix