From 427025b8168568962b7b1dbdf8151c63e4912762 Mon Sep 17 00:00:00 2001 From: William Phetsinorath Date: Fri, 16 Jan 2026 18:25:26 +0100 Subject: [PATCH] Update [ghstack-poisoned] --- LICENSE | 3 +- flake.lock | 6 +- flake.nix | 25 ++++-- modules/devenv/integrations/license.nix | 105 ++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 modules/devenv/integrations/license.nix diff --git a/LICENSE b/LICENSE index b8bfae5..912a24a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 William Phetsinorath + Copyright 2025 Shikanime Studio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flake.lock b/flake.lock index 014244d..817531e 100644 --- a/flake.lock +++ b/flake.lock @@ -50,11 +50,11 @@ ] }, "locked": { - "lastModified": 1768495715, - "narHash": "sha256-1RVQjA6GYKJnBUV1ZJ66ULC4Aj5rk8b6JyoHF9E/YNM=", + "lastModified": 1768572621, + "narHash": "sha256-rS2jTj1fWCXO796egDcIsD71CBEr5ZXjF/LUzz5U8Ug=", "owner": "cachix", "repo": "devenv", - "rev": "23729dc54bbca0f36878ae2935cbfea834335f1a", + "rev": "752d1234cf6183cd43439e08f4d519c56f0dc19d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 523292a..23b3096 100755 --- a/flake.nix +++ b/flake.nix @@ -127,15 +127,24 @@ }; perSystem = - { pkgs, ... }: + { config, pkgs, ... }: { - devenv.shells.default.imports = [ - self.devenvModules.git - self.devenvModules.github - self.devenvModules.nix - self.devenvModules.shell - self.devenvModules.shikanime-studio - ]; + devenv.shells.default = { + imports = [ + self.devenvModules.git + self.devenvModules.github + self.devenvModules.nix + self.devenvModules.shell + self.devenvModules.shikanime-studio + ]; + license = { + enable = true; + holder = "Shikanime Studio"; + package = config.devenv.shells.default.license.lib.pkgs.asl20; + year = "2025"; + }; + }; + packages = { fleet = pkgs.callPackage ./pkgs/fleet { }; bootloose = pkgs.callPackage ./pkgs/bootloose { }; diff --git a/modules/devenv/integrations/license.nix b/modules/devenv/integrations/license.nix new file mode 100644 index 0000000..5b13b77 --- /dev/null +++ b/modules/devenv/integrations/license.nix @@ -0,0 +1,105 @@ +{ + config, + lib, + pkgs, + ... +}: + +with lib; + +let + cfg = config.license; +in +{ + options.license = { + enable = mkEnableOption "license generation"; + + package = mkOption { + type = types.functionTo types.package; + default = license.generate; + description = "License generator function."; + }; + + lib = lib.mkOption { + type = lib.types.attrsOf lib.types.anything; + }; + + holder = mkOption { + type = types.str; + description = "Copyright holder."; + }; + + year = mkOption { + type = types.str; + description = "Override year; null lets the generator use the current year."; + }; + + description = mkOption { + type = types.str; + description = "Project description to use in the license text (unused for some licenses)."; + }; + }; + + config = mkIf cfg.enable { + license.lib.pkgs = { + agpl3Only = + let + template = builtins.fetchurl { + url = "https://www.gnu.org/licenses/agpl-3.0.txt"; + sha256 = "1c5wk83xn43pma39yf6xm0mr312iinqi7xrh3xplnvddd3zs95hd"; + }; + in + { + year, + holder, + description, + }: + pkgs.runCommand "LICENSE" { inherit year holder description; } '' + ${pkgs.gnused}/bin/sed \ + -e "s//$description/g" \ + -e "s//$year/g" \ + -e "s//$holder/g" \ + ${template} > $out + ''; + + asl20 = + let + template = builtins.fetchurl { + url = "https://www.apache.org/licenses/LICENSE-2.0.txt"; + sha256 = "0c1xaay1fd00xgri0z447q2i8s3mpxqw9da27hfd6fznjsdp9iyg"; + }; + in + { year, holder, ... }: + pkgs.runCommand "LICENSE" { inherit year holder; } '' + ${pkgs.gnused}/bin/sed \ + -e "s/\[yyyy\]/$year/g" \ + -e "s/\[name of copyright owner\]/$holder/g" \ + ${template} > $out + ''; + + mit = + let + template = builtins.fetchurl { + url = "https://raw.githubusercontent.com/github/choosealicense.com/gh-pages/_licenses/mit.txt"; + sha256 = "1f7m7v5af7pk46m7q2qi3xp51x6hjvclh44dj47k1cxc7jqrv4g6"; + }; + in + { year, holder, ... }: + pkgs.runCommand "LICENSE" { inherit year holder; } '' + ${pkgs.gnused}/bin/sed \ + -e '/^---$/,/^---$/d' \ + -e "s/\[year\]/$year/g" \ + -e "s/\[fullname\]/$holder/g" \ + ${template} > $out + ''; + }; + + tasks."devlib:license:install" = { + before = [ "devenv:enterShell" ]; + description = "Install LICENSE file"; + exec = '' + ${pkgs.coreutils}/bin/cat ${cfg.package { inherit (cfg) year holder description; }} > LICENSE + ''; + }; + }; +}