diff --git a/changelog.md b/changelog.md index f7ce493d..a1aed825 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ * Allow multiple flags to be passed as a list in the OCs `enable`, `disable` and `configure`. * Apply the `buildInputs` OC to `pkgs` when it is a function, as documented. * Apply package-set and env OCs separately when reading pregenerated overrides. +* Add OC `github` as a convenience wrapper of `source`. ### Environments and toolchain diff --git a/lib/deps/api.nix b/lib/deps/api.nix index 00cebaf6..90487497 100644 --- a/lib/deps/api.nix +++ b/lib/deps/api.nix @@ -108,13 +108,18 @@ let else c2n.hackageAt conf.location ; + + github = {owner, repo, rev, hash, path ? null}: let + src = config.pkgs.fetchFromGitHub { inherit owner repo rev hash; }; + in if path == null then c2n.source.root src else c2n.source.sub src path; + in transformers // { inherit (c2n) hackageAt source; inherit self super pkgs; final = self; prev = super; inherit reset transform transform_ noHpack cabalOverrides cabal2nixOverrides cabal2nixArgs revision drv; - inherit hackageConfGen hackageConf hackage; + inherit hackageConfGen hackageConf hackage github; inherit (spec) option; hsLib = pkgs.haskell.lib; inherit hsLibC; diff --git a/lib/release.nix b/lib/release.nix index 09f4afe4..52556884 100644 --- a/lib/release.nix +++ b/lib/release.nix @@ -129,6 +129,7 @@ sed -i 's/ref=[^"#]\+/ref='"$version/" readme.md examples/*/flake.nix sed -ri 's/~[[:digit:]]+\.[[:digit:]]+\.tar/~'"''${version%.*}.tar/" readme.md sed -i 's/hixVersion = ".*"/hixVersion = "'"$version"'"/' modules/basic.nix packages/hix/lib/Hix.hs + sed -i 's/hixRelease = false/hixRelease = true/' modules/basic.nix sed -i "s/Unreleased/$version/" changelog.md sed -i '/cliReleaseOverride/ s/false/true/' modules/hix-test.nix sed -i "s/@since unreleased/@since $version/" packages/**/*.hs @@ -145,6 +146,9 @@ ask_abort 'Ready to commit. Continue?' ${git} commit --allow-empty -m "Release $version" ${git} tag -m "Release $version" "$version" + sed -i 's/hixRelease = true/hixRelease = false/' modules/basic.nix + ${git} add modules/basic.nix + ${git} commit --allow-empty -m "Reset release option" ''; grepDevCli = "${grep} --files-with-matches 'hixCli\.dev = true'"; diff --git a/local.nix b/local.nix index bb6b8abd..1b4c2162 100644 --- a/local.nix +++ b/local.nix @@ -271,11 +271,6 @@ in { internal.cabal-extra.default-extensions = ["StrictData"]; - internal.hixCli = { - commit = "d14e85f7aee0878665484663e9f95347b7beb80d"; - sha256 = "0disvvvvv9wwckvg6ybvjas72vg6p4nhcbcswdpddikxhs1xy9xj"; - }; - outputs = let # The test runner does not copy `./test` to the temporary directory. diff --git a/modules/basic.nix b/modules/basic.nix index d1a06e9a..99d47e65 100644 --- a/modules/basic.nix +++ b/modules/basic.nix @@ -289,6 +289,12 @@ in { readOnly = true; }; + hixRelease = mkOption { + description = "Whether this project uses a release version of Hix."; + type = bool; + default = true; + }; + hixUrl = mkOption { description = "The URL to the Hix release tag used by this project."; type = str; @@ -352,6 +358,8 @@ in { hixVersion = "0.9.1"; + hixRelease = false; + }; }; } diff --git a/modules/cli.nix b/modules/cli.nix index e5e907f9..01ec4483 100644 --- a/modules/cli.nix +++ b/modules/cli.nix @@ -3,11 +3,6 @@ let inherit (lib) types; inherit (util) build; - cliNixpkgs = config.pkgs.fetchzip { - url = "https://github.com/nixos/nixpkgs/archive/a7fc11be66bdfb5cdde611ee5ce381c183da8386.tar.gz"; - sha256 = "0h3gvjbrlkvxhbxpy01n603ixv0pjy19n9kf73rdkchdvqcn70j2"; - }; - package-set = build.package-sets config.internal.hixCli.ghc; in { @@ -40,7 +35,7 @@ in { default = null; }; - sha256 = lib.mkOption { + hash = lib.mkOption { description = '' If `commit` is configured, this is the corresponding source hash. Initially the empty string, you can add the value after the first build attempt by copying it from the error @@ -75,32 +70,44 @@ in { config.internal.hixCli = { - overrides = {hackage, source, minimal, jailbreak, super, ...}: let + commit = lib.mkIf (!config.internal.hixRelease) (lib.mkDefault "b79cf30e9275ade0b0303fce3dbb772bb1cb59b0"); + + hash = "sha256-xht1kRRnFOslSiDPgahg0AuXjL84bZINYrXCcVaZjtI="; + + overrides = {hackage, source, github, minimal, jailbreak, ...}: let conf = config.internal.hixCli; - githubSrc = builtins.fetchTarball { - url = "https://github.com/tek/hix/archive/${conf.commit}.tar.gz"; - inherit (conf) sha256; + githubArgs = { + owner = "tek"; + repo = "hix"; + rev = conf.commit; + inherit (conf) hash; + path = "packages/hix"; }; - devHix = source.package (if conf.commit == null then ../. else githubSrc) "hix"; - prodHix = let meta = import ../ops/cli-dep.nix; - in jailbreak (hackage meta.version meta.sha256); - - useDev = conf.commit != null || conf.dev; + in hackage meta.version meta.sha256; - hix = if useDev then devHix else prodHix; + hix = + if conf.dev + then source.package ../. "hix" + else if conf.commit != null + then github githubArgs + else prodHix + ; - in { hix = minimal hix; }; + in { hix = jailbreak (minimal hix); }; ghc = { name = "hix"; compiler = { nixpkgs = { - source = cliNixpkgs; + source = { + rev = "a7fc11be66bdfb5cdde611ee5ce381c183da8386"; + hash = "sha256:0h3gvjbrlkvxhbxpy01n603ixv0pjy19n9kf73rdkchdvqcn70j2"; + }; extends = null; }; source = "ghc912"; diff --git a/packages/hix/lib/Hix/Managed/Data/ReleaseConfig.hs b/packages/hix/lib/Hix/Managed/Data/ReleaseConfig.hs index efdbf275..05a8812e 100644 --- a/packages/hix/lib/Hix/Managed/Data/ReleaseConfig.hs +++ b/packages/hix/lib/Hix/Managed/Data/ReleaseConfig.hs @@ -58,7 +58,6 @@ data ReleaseConfig = -- | Run Nix flake checks before uploading. Defaults to False; must be explicitly enabled with --check. check :: Bool, -- | Merge the release branch back into the initial branch after successful uploads. - -- A temporary release branch is always created. Use --merge to merge it back. merge :: Bool, -- | Use the global Cabal configuration file instead of hermetic @/dev/null@. -- This allows using credentials configured in @~\/.cabal\/config@ but sacrifices reproducibility.