From 75eac3e74bb849006aad8f996db409adcc97aaed Mon Sep 17 00:00:00 2001 From: RGBCube Date: Wed, 15 May 2024 13:36:51 +0300 Subject: [PATCH] Add README, LICENSE and clean up flake.nix --- .gitignore | 1 + LICENSE.md | 21 +++++++++++++ README.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 24 +++++++++------ package.nix | 4 +-- 5 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 LICENSE.md create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 9bb20ad..41c4445 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ !.gitignore !*.lock +!*.md !*.nix !*.zig !*.zon diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..09752d7 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2024-present RGBCube + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed423dd --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +# crash + +A user-configurable login shell wrapper. + +Crash is a super lightweight shim that executes the shells that are seperated by `:` +in your `SHELLS` environment variable in order, halting execution if one exits +sucessfully (with a 0 exit code). + +If you don't have anything in your `SHELLS` environment variable, Crash will +use the fallback shell that is configured at compile time (by default, this is +`bashInteractive` from nixpkgs, however you can change this by overriding the +`fallbackShell` call option). + +## Why? + +- To allow users to configure their own shells without superuser access. +- To have a fallback shell in case your primary one breaks (especially useful when + using new unstable shells like Nushell). + +## Installation + +Simply add this repository to your inputs like so: + +```nix +{ + inputs.crash = { + url = "github:RGBCube/crash"; + inputs.nixpkgs.follows = "nixpkgs"; + }; +} +``` + +And then you can set the package as your default user +shell like so, in a NixOS module: + +```nix +{ + outputs = { nixpkgs, crash }: { + nixosConfigurations.myhostname = nixpkgs.lib.nixosSystem { + modules = [ + ({ pkgs, lib, ... }: { + nixpkgs.overlays = [ crash.overlays.default ]; + + users.defaultUserShell = pkgs.crash; + + # Here we set our default shells. Nushell will be tried first, if that + # exits with an error, fish will be launched instead. And if fish fails, the + # fallback shell, which is pkgs.bashInteractive will get run. + environment.sessionVariables.SHELLS = "${lib.getExe pkgs.nushell}:${lib.getExe pkgs.fish}"; + }) + + # Uncomment to make the fallback shell of crash pkgs.dash. Will require a recompilation! + # { + # nixpkgs.overlays = [(final: prev: { + # crash = prev.crash.override { fallbackShell = final.dash }; + # })]; + # } + ]; + }; + } +} +``` + +## License + +``` +Copyright (c) 2024-present RGBCube + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/flake.nix b/flake.nix index eb7b337..e9a61be 100644 --- a/flake.nix +++ b/flake.nix @@ -8,21 +8,27 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = { nixpkgs, ... }: with nixpkgs.lib; foldl' recursiveUpdate {} (map (system: let - pkgs = import nixpkgs { inherit system; }; + outputs = { self, nixpkgs }: let + inherit (nixpkgs) lib; + + forEachSystem = lib.genAttrs [ "x86_64-linux" "aarch64-linux" "riscv64-linux" ]; in { - devShell.${system} = pkgs.mkShell { - packages = with pkgs; [ + devShell = forEachSystem (system: with nixpkgs.legacyPackages.${system}; mkShell { + packages = [ zig_0_12 zls zon2nix ]; - }; + }); - packages.${system} = rec { - crash = pkgs.callPackage ./package.nix {}; + packages = forEachSystem (system: rec { + inherit (self.overlays.crash null nixpkgs.legacyPackages.${system}) crash; + default = crash; + }); + + overlays = rec { + crash = (final: prev: { crash = prev.callPackage ./package.nix {}; }); default = crash; }; - - }) [ "x86_64-linux" "aarch64-linux" "riscv64-linux" ]); + }; } diff --git a/package.nix b/package.nix index da12f22..bad26d8 100644 --- a/package.nix +++ b/package.nix @@ -6,8 +6,8 @@ zig_0_12, optimize ? "ReleaseFast", - bash, - fallbackShell ? bash, + bashInteractive, + fallbackShell ? bashInteractive, }: stdenvNoCC.mkDerivation {