diff --git a/.gitignore b/.gitignore index c44119d..72d93e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ config_priv/* !config_priv/README.md !config_priv/examples + +# nix +result diff --git a/README.md b/README.md index 4920b41..6ed3e82 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ multios-usb -l # Install to the selected device (replace sdX with your target device) sudo multios-usb /dev/sdX +``` +**Nix/NixOS** + +```nix +# run without permanent install (flakes must be enabled) +sudo nix run github:Mexit/MultiOS-USB -- /dev/sdX + +# create shell with MultiOS-USB available +nix shell github:Mexit/MultiOS-USB + ``` **From GitHub - Linux console** diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..427d5af --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1754487366, + "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1756125398, + "narHash": "sha256-XexyKZpf46cMiO5Vbj+dWSAXOnr285GHsMch8FBoHbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3b9f00d7a7bf68acd4c4abb9d43695afb04e03a5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1753579242, + "narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a2b4a4b --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + description = "MultiOS-USB: One device with muliple ISO/WIM files"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + gitignore = { + url = "github:hercules-ci/gitignore.nix"; + # Use the same nixpkgs + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ]; + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + perSystem = + { + config, + self', + inputs', + pkgs, + system, + ... + }: + let + inherit (inputs.gitignore.lib) gitignoreSource; + in + { + packages.default = pkgs.stdenv.mkDerivation rec { + src = gitignoreSource ./.; + name = "multios-usb"; + buildInputs = with pkgs; [ + gnutar + xz + bzip2 + gptfdisk + util-linux + exfat + dosfstools + ]; + nativeBuildInputs = with pkgs; [ makeWrapper ]; + buildPhase = '' + mkdir -p $out/bin + cp -r $src $out/share + ln -s $src/multios-usb.sh $out/bin/multios-usb + ''; + postFixup = '' + wrapProgram $out/bin/multios-usb \ + --chdir $out/share \ + --prefix PATH : ${pkgs.lib.makeBinPath buildInputs} + ''; + }; + }; + flake = { + }; + }; +} diff --git a/multios-usb.sh b/multios-usb.sh index 1eab8b0..78eaf61 100755 --- a/multios-usb.sh +++ b/multios-usb.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # MultiOS-USB © 2020-2025 MexIT # https://gitlab.com/MultiOS-USB @@ -34,6 +34,7 @@ trap '{ }' EXIT cd "$(dirname "$(readlink -f "$0")")" + echo "Arguments: $*" > $log_file showUsage() {