-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rationale: https://ayats.org/blog/no-flake-utils/
- Loading branch information
Showing
2 changed files
with
61 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,73 @@ | ||
{ | ||
description = "Nix fether for Steam games"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; | ||
|
||
outputs = { | ||
self, | ||
nixpkgs, | ||
flake-utils, | ||
}: | ||
with flake-utils.lib; | ||
}: let | ||
# DepotDownloader only supports x86_64 Linux. | ||
eachSystem ["x86_64-linux"] (system: let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; | ||
overlays = [self.overlays.default]; | ||
}; | ||
supportedSystems = ["x86_64-linux"]; | ||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
pkgsFor = system: | ||
import nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; | ||
overlays = [self.overlays.default]; | ||
}; | ||
lintersFor = system: let | ||
pkgs = pkgsFor system; | ||
in | ||
with pkgs; [ | ||
alejandra | ||
statix | ||
shellcheck | ||
shfmt | ||
]; | ||
in { | ||
devShells = forAllSystems (system: let | ||
pkgs = pkgsFor system; | ||
in { | ||
default = pkgs.mkShell { | ||
packages = with pkgs; | ||
[ | ||
nil # Nix LS | ||
nodePackages.bash-language-server | ||
] | ||
++ (lintersFor system); | ||
}; | ||
}); | ||
|
||
linters = with pkgs; [ | ||
alejandra | ||
statix | ||
shellcheck | ||
shfmt | ||
]; | ||
in { | ||
devShells = { | ||
default = pkgs.mkShell { | ||
packages = with pkgs; | ||
[ | ||
nil # Nix LS | ||
nodePackages.bash-language-server | ||
] | ||
++ linters; | ||
}; | ||
}; | ||
checks = forAllSystems (system: let | ||
pkgs = pkgsFor system; | ||
in | ||
builtins.mapAttrs (name: pkgs.runCommandLocal name {nativeBuildInputs = lintersFor system;}) { | ||
alejandra = "alejandra --check ${./.} > $out"; | ||
shellcheck = "shellcheck $(${pkgs.shfmt}/bin/shfmt --find ${./.}) > $out"; | ||
shfmt = "shfmt --simplify --diff ${./.} > $out"; | ||
statix = "statix check ${./.} > $out"; | ||
} | ||
// { | ||
inherit (pkgs) steamworks-sdk-redist; | ||
}); | ||
|
||
checks = | ||
builtins.mapAttrs (name: pkgs.runCommandLocal name {nativeBuildInputs = linters;}) { | ||
alejandra = "alejandra --check ${./.} > $out"; | ||
shellcheck = "shellcheck $(${pkgs.shfmt}/bin/shfmt --find ${./.}) > $out"; | ||
shfmt = "shfmt --simplify --diff ${./.} > $out"; | ||
statix = "statix check ${./.} > $out"; | ||
} | ||
// { | ||
inherit (pkgs) steamworks-sdk-redist; | ||
}; | ||
formatter = forAllSystems (system: let | ||
pkgs = pkgsFor system; | ||
in | ||
pkgs.writeShellApplication { | ||
name = "fmt"; | ||
runtimeInputs = lintersFor system; | ||
text = '' | ||
alejandra --quiet . | ||
statix fix . | ||
shfmt --simplify --write . | ||
''; | ||
}); | ||
|
||
formatter = pkgs.writeShellApplication { | ||
name = "fmt"; | ||
runtimeInputs = linters; | ||
text = '' | ||
alejandra --quiet . | ||
statix fix . | ||
shfmt --simplify --write . | ||
''; | ||
}; | ||
}) | ||
// { | ||
overlays.default = final: prev: { | ||
fetchSteam = final.callPackage ./fetch-steam {}; | ||
steamworks-sdk-redist = final.callPackage ./steamworks-sdk-redist {}; | ||
}; | ||
}; | ||
overlays.default = final: prev: { | ||
fetchSteam = final.callPackage ./fetch-steam {}; | ||
steamworks-sdk-redist = final.callPackage ./steamworks-sdk-redist {}; | ||
}; | ||
}; | ||
} |