This commit is contained in:
2023-06-10 13:27:11 +02:00
parent f94832abf7
commit c731aa6a98

View File

@@ -9,16 +9,17 @@
let let
name = "patch-manjaro-sway-mirror-for-arm"; name = "patch-manjaro-sway-mirror-for-arm";
version = "0.0.1"; version = "0.0.1";
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
packages = forAllSystems (system: rec packages = forAllSystems (system: rec {
{
default = nixpkgsFor.${system}.stdenv.mkDerivation { default = nixpkgsFor.${system}.stdenv.mkDerivation {
name = name; name = name;
src = self; src = self;
buildPhase = ""; buildPhase = "";
installPhase = "mkdir -p $out/bin; install -t $out/bin src/patch-manjaro-sway-mirror-for-arm.sh"; installPhase =
"mkdir -p $out/bin; install -t $out/bin src/patch-manjaro-sway-mirror-for-arm.sh";
}; };
pkgbuildFile = nixpkgsFor.${system}.writeTextFile { pkgbuildFile = nixpkgsFor.${system}.writeTextFile {
name = "PKGBUILD"; name = "PKGBUILD";
@@ -36,7 +37,8 @@
} }
''; '';
}; };
buildScriptdFile = nixpkgsFor.${system}.writeShellScript "build-package.sh" '' buildScriptdFile =
nixpkgsFor.${system}.writeShellScript "build-package.sh" ''
temp_folder=$(mktemp -d) temp_folder=$(mktemp -d)
pushd "$temp_folder" pushd "$temp_folder"
@@ -48,38 +50,50 @@
rm -rf "$temp_folder" rm -rf "$temp_folder"
''; '';
}); });
devTaskScripts = forAllSystems (system: devTaskScripts = forAllSystems (system: {
{
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" '' autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
git tag --force v${version} git tag --force v${version}
git push origin v${version} git push origin v${version}
''; '';
}); });
in in {
{
packages = packages; packages = packages;
apps = forAllSystems (system: apps = forAllSystems (system:
let let
updateLockScript = nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" '' updateLockScript =
nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
nix --experimental-features 'nix-command flakes' build nix --experimental-features 'nix-command flakes' build
''; '';
in in {
{ default = {
default = { type = "app"; program = "${packages.${system}.default}/bin/patch-manjaro-sway-mirror-for-arm.sh"; }; type = "app";
buildPackage = { type = "app"; program = "${packages.${system}.buildScriptdFile}"; }; program = "${
packages.${system}.default
}/bin/patch-manjaro-sway-mirror-for-arm.sh";
};
buildPackage = {
type = "app";
program = "${packages.${system}.buildScriptdFile}";
};
devTasks = { devTasks = {
updateFlakeLock = { type = "app"; program = "${updateLockScript}/bin/update_flake_lock.sh"; }; updateFlakeLock = {
autoTag = { type = "app"; program = "${devTaskScripts.${system}.autoTag}"; }; type = "app";
program = "${updateLockScript}/bin/update_flake_lock.sh";
};
autoTag = {
type = "app";
program = "${devTaskScripts.${system}.autoTag}";
};
}; };
}); });
devShells = forAllSystems (system: devShells = forAllSystems (system: {
{
default = nixpkgsFor.${system}.mkShell { default = nixpkgsFor.${system}.mkShell {
name = "dev-shell"; name = "dev-shell";
packages = [ nixpkgsFor.${system}.nixpkgs-fmt nixpkgsFor.${system}.shellspec ]; packages =
[ nixpkgsFor.${system}.nixpkgs-fmt nixpkgsFor.${system}.shellspec ];
shellHook = '' shellHook = ''
. alias.sh . alias.sh
''; '';