Overhaul nix flake (#279)

This commit is contained in:
ozwaldorf 2024-04-10 00:58:34 -04:00 committed by GitHub
parent 2bd366f337
commit 8afe66ab31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 73 deletions

View file

@ -1,28 +1,12 @@
{
"nodes": {
"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"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1684585791,
"narHash": "sha256-lYPboblKrchmbkGMoAcAivomiOscZCjtGxxTSCY51SM=",
"lastModified": 1712192574,
"narHash": "sha256-LbbVOliJKTF4Zl2b9salumvdMXuQBr2kuKP5+ZwbYq4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "eea79d584eff53bf7a76aeb63f8845da6d386129",
"rev": "f480f9d09e4b4cf87ee6151eba068197125714de",
"type": "github"
},
"original": {
@ -34,7 +18,6 @@
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
}
}

100
flake.nix
View file

@ -1,73 +1,67 @@
{
description = "swaywm development environment";
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs, flake-compat, ... }:
description = "Swayfx development environment";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs, ... }:
let
pkgsFor = system:
import nixpkgs {
inherit system;
overlays = [ ];
};
targetSystems = [ "aarch64-linux" "x86_64-linux" ];
pkgsFor = system: import nixpkgs { inherit system; };
targetSystems = [
"aarch64-linux"
"x86_64-linux"
];
mkPackage = pkgs: {
swayfx-unwrapped =
(pkgs.swayfx-unwrapped.override {
# When the sway 1.9 rebase is finished, this will need to be overridden.
# wlroots_0_16 = pkgs.wlroots_0_16;
}).overrideAttrs
(old: {
version = "0.3.2-git";
src = pkgs.lib.cleanSource ./.;
});
};
in
{
overlays.default = final: prev: {
swayfx-unwrapped = prev.sway-unwrapped.overrideAttrs (old: {
src = builtins.path { path = prev.lib.cleanSource ./.; };
patches =
let
removePatches = [
"LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM.patch"
];
in
builtins.filter
(patch: !builtins.elem (patch.name or null) removePatches)
(old.patches or [ ]);
});
overlays = rec {
default = override;
# Override onto the input nixpkgs
override = _: prev: mkPackage prev;
# Insert using the locked nixpkgs
insert = _: prev: mkPackage (pkgsFor prev.system);
};
packages = nixpkgs.lib.genAttrs targetSystems (system:
let pkgs = pkgsFor system;
in (self.overlays.default pkgs pkgs) // {
default = self.packages.${system}.swayfx-unwrapped;
});
packages = nixpkgs.lib.genAttrs targetSystems (
system: (mkPackage (pkgsFor system) // { default = self.packages.${system}.swayfx-unwrapped; })
);
devShells = nixpkgs.lib.genAttrs targetSystems (system:
devShells = nixpkgs.lib.genAttrs targetSystems (
system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell {
name = "swayfx-shell";
depsBuildBuild = with pkgs; [ pkg-config ];
inputsFrom = [ self.packages.${system}.swayfx-unwrapped pkgs.wlroots_0_16 ];
inputsFrom = [
self.packages.${system}.swayfx-unwrapped
pkgs.wlroots_0_16
];
nativeBuildInputs = with pkgs; [
cmake
meson
ninja
pkg-config
wayland-scanner
scdoc
hwdata # for wlroots
];
shellHook = with pkgs; ''(
mkdir -p "$PWD/subprojects"
cd "$PWD/subprojects"
cp -R --no-preserve=mode,ownership ${wlroots_0_16.src} wlroots
)'';
# Copy the nix version of wlroots into the project
shellHook = with pkgs; ''
(
mkdir -p "$PWD/subprojects" && cd "$PWD/subprojects"
cp -R --no-preserve=mode,ownership ${wlroots_0_16.src} wlroots
)'';
};
});
}
);
formatter = nixpkgs.lib.genAttrs targetSystems (system: {
default = (pkgsFor system).nixfmt-rfc-style;
});
};
}