Refactor to flake-utils.

Reduce boilerplate and add `apps` and `devShells`.
This commit is contained in:
Lyle Mantooth 2023-12-17 16:50:49 -05:00
parent d869a9e31f
commit e7bd971451
Signed by: IslandUsurper
GPG key ID: 6DB52EAE123A5789
2 changed files with 97 additions and 50 deletions

View file

@ -1,24 +1,58 @@
{ {
"nodes": { "nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1702645756, "lastModified": 1702846620,
"narHash": "sha256-qKI6OR3TYJYQB3Q8mAZ+DG4o/BR9ptcv9UnRV2hzljc=", "narHash": "sha256-45K8VhHgE8cSPUgm5ixOTtmplWGXJN4ozNvjmEVSYGc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "40c3c94c241286dd2243ea34d3aef8a488f9e4d0", "rev": "50b80afb13c6bcf8cc4be7e1fbd7719a85c487cb",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-23.11", "ref": "release-23.11",
"type": "indirect" "type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"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", "root": "root",

View file

@ -2,30 +2,24 @@
description = "Super Nintendo Interface"; description = "Super Nintendo Interface";
# Nixpkgs / NixOS version to use. # Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-23.11"; inputs.nixpkgs.url = "nixpkgs/release-23.11";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
flake-utils,
}: let }: let
# to work with older version of flakes # to work with older version of flakes
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101"; lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
version = "0.0.95"; version = "0.0.95";
in
# System types to support. flake-utils.lib.eachDefaultSystem (system: let
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; pkgs = nixpkgs.legacyPackages.${system};
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;});
in { in {
# Provide some binary packages for selected system types. # Provide some binary packages for selected system types.
packages = forAllSystems (system: let packages = rec {
pkgs = nixpkgsFor.${system};
in rec {
default = sni; default = sni;
sni = pkgs.buildGoModule { sni = pkgs.buildGoModule {
@ -66,6 +60,25 @@
maintainers = with maintainers; [island_usurper]; maintainers = with maintainers; [island_usurper];
}; };
}; };
});
apps = rec {
sni = {
type = "app";
program = "${self.packages.${system}.sni}/bin/sni";
}; };
default = sni;
};
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
go
gtk3.dev
libayatana-appindicator.dev
pkg-config
];
};
};
};
});
} }