├── .circleci └── config.yml ├── .gitignore ├── Changelog.md ├── LICENSE ├── README.md ├── build.nix ├── default.nix ├── exe └── Main.hs ├── fixtures ├── gobanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── gobanme-no-purojekuto.cabal │ └── setup_test.sh ├── gobanme-no-yagai-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── gobanme-no-yagai-purojekuto.cabal │ └── setup_test.sh ├── hachibanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── hachibanme-no-purojekuto.cabal │ └── setup_test.sh ├── ichibanme-no-yagai-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── ichibanme-no-yagai-purojekuto.cabal │ └── setup_test.sh ├── jyuubanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── jyuubanme-no-purojekuto.cabal │ ├── setup_test.sh │ └── test.sh ├── jyuuichibanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── jyuuichibanme-no-purojekuto.cabal │ ├── setup_test.sh │ ├── test.sh │ └── with-options.nix ├── kyuubanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── kyuubanme-no-purojekuto.cabal │ └── setup_test.sh ├── nanabanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── nanabanme-no-purojekuto.cabal │ ├── setup_test.sh │ └── test.sh ├── new_fixture_dir.sh ├── nibanme-no-yagai-purojekuto │ ├── DESC │ ├── nibanme-no-yagi-purojekuto.cabal │ ├── setup_test.sh │ └── test.sh ├── rokubanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── rokubanme-no-purojekuto.cabal │ └── setup_test.sh ├── sanbanme-no-yagai-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── sanbanme-no-yagai-purojekuto.cabal │ └── setup_test.sh ├── yonbanme-no-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── setup_test.sh │ └── yonbanme-no-purojekuto.cabal └── yonbanme-no-yagai-purojekuto │ ├── .gitignore │ ├── DESC │ ├── LICENSE │ ├── Main.hs │ ├── default.nix │ ├── setup_test.sh │ └── yonbanme-no-yagai-purojekuto.cabal ├── haskell-overridez.cabal ├── lib.nix ├── nix ├── 18.09.nix ├── fetchNixPkgs.nix ├── fetchPkgsMake.nix └── wrapper │ └── default.nix ├── shell.nix └── test.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | aliases: &build 4 | environment: 5 | BASH_ENV: "~/.nix-profile/etc/profile.d/nix.sh" 6 | 7 | machine: true 8 | 9 | parallelism: 2 10 | 11 | steps: 12 | - checkout 13 | 14 | - run: 15 | name: create a fake /nix 16 | command: sudo mkdir -m 0755 /nix && sudo chown circleci /nix 17 | 18 | # Restore the nix installation to its state after the previous test run. 19 | # This should prevent unnecessary rebuilds of dependencies without impacting 20 | # the tests themselves. 21 | 22 | - restore_cache: 23 | keys: 24 | - nix-root-v1-{{ arch }}-{{ checksum "build.nix" }} 25 | 26 | - restore_cache: 27 | keys: 28 | - nix-dotnix-v1-{{ arch }}-{{ checksum "build.nix" }} 29 | 30 | - run: 31 | name: install nix 32 | command: | 33 | [[ -d ~/.nix-defexpr ]] || 34 | curl https://nixos.org/nix/install | sh 35 | 36 | - run: 37 | name: install nix dependencies used in the test script itself 38 | command: | 39 | nix-env -i cabal2nix 40 | nix-env -i nix-prefetch-git 41 | 42 | - run: 43 | name: run the tests (temporarily - just build to reset the cache) 44 | command: nix-build --show-trace build.nix 45 | 46 | # Save /nix and the nix user folders to the cache. 47 | 48 | - save_cache: 49 | key: nix-root-v1-{{ arch }}-{{ checksum "build.nix" }} 50 | paths: 51 | - /nix 52 | 53 | - save_cache: 54 | key: nix-dotnix-v1-{{ arch }}-{{ checksum "build.nix" }} 55 | paths: 56 | - ~/.nix-profile 57 | - ~/.nix-defexpr 58 | 59 | jobs: 60 | build: *build 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # haskell development 2 | result 3 | .ghc* 4 | dist 5 | dist-newstyle 6 | .DS_Store -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog for haskell-overridez 2 | All notable changes to this project will be documented in this file. 3 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 4 | and this project adheres to [Haskell PVP](https://pvp.haskell.org). 5 | 6 | ## [Unreleased] 7 | ### Added 8 | * --cabal-opts as a flag for specifying cabal override options 9 | ### Removed (breaking change) 10 | * using the HOZ_OPTS environment variable to specify cabal override options 11 | 12 | ## 0.10.3.1 13 | * there is no ChangeLog as of this release 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # haskell-overridez [![CircleCI](https://circleci.com/gh/adetokunbo/haskell-overridez.svg?style=svg)](https://circleci.com/gh/adetokunbo/haskell-overridez) 2 | 3 | __haskell-overridez__ is a tool and library of nix functions that simplify the use of overrides while developing haskell projects with [nixpkgs](https://github.com/NixOS/nixpkgs). 4 | 5 | ## Inspiration 6 | 7 | __haskell-overridez__ is inspired by the section on [Advanced Dependency Management](https://github.com/Gabriel439/haskell-nix/tree/master/project4) in [haskell-nix](https://github.com/Gabriel439/haskell-nix). 8 | The idea is to turn the recommendations there into a tool that is itself installed into the nix environment. 9 | 10 | 11 | ## Installation 12 | 13 | It's assumed that you have already [installed nix](https://nixos.wiki/wiki/Nix_Installation_Guide). 14 | 15 | You can then install `haskell-overridez` using `nix-env`: 16 | 17 | ```bash 18 | 19 | nix-env --install -f https://github.com/adetokunbo/haskell-overridez/archive/v0.10.3.1.tar.gz 20 | 21 | ``` 22 | 23 | ## Basic usage 24 | 25 | Installation adds the executable `haskell-overridez` to the nix environment. 26 | 27 | It writes the output of the other tools it uses to subdirectories of the development project. 28 | 29 | E.g, 30 | 31 | ```bash 32 | $ cd my-nix-project 33 | 34 | # install an override using github json 35 | $ haskell-overridez -g reflex-frp/reflex-dom-contrib 36 | 37 | # install an override using cabal2nix 38 | $ haskell-overridez https://github.com/tathougies/beam -- --subpath beam-core 39 | ``` 40 | 41 | There are various options for managing the overrides; to see them all, you can read the help message: 42 | 43 | ```bash 44 | $ haskell-overridez -h 45 | haskell-overridez - manage nix overrides for haskell packages 46 | ... 47 | 48 | ``` 49 | 50 | ### Project Layout 51 | 52 | Given the previous example commands, `haskell-overridez` creates a project with the following layout: 53 | 54 | ``` 55 | ├── default.nix 56 | │ 57 | ├── nix (1) 58 | │   │ 59 | │   ├── haskell-overridez.nix (2) 60 | │   │ 61 | │   ├── nix-expr (3) 62 | │   │   └── beam-core.nix 63 | │   │ 64 | │   ├── git-json (3) 65 | │   │   └── reflex-dom-contrib.json 66 | ``` 67 | 68 | 1. There is a `nix` subdirectory of the main project directory. 69 | 2. There is a `haskell-overridez.nix` file that contains the nix expression used to load the accompanying nix expression library. 70 | 3. There are subdirectories (`nix-expr`, `git-json`) that contain the output from the tools. 71 | 4. The accompanying library functions use the contents of the subdirectories to generate a nix expression that combines all the overrides into a single nix overlay. 72 | 73 | ### Using the library functions 74 | 75 | The library functions can be used from `default.nix` by setting the `overlays` attribute. 76 | 77 | ```nix 78 | 79 | let 80 | overridez = import ./nix/haskell-overridez.nix; 81 | overlays = [ 82 | (newPkgs: oldPkgs: { 83 | haskellPackages = oldPkgs.haskellPackages.override { 84 | overrides = overridez.allIn ./nix; 85 | }; 86 | }) 87 | ]; 88 | pkgs = import { inherit overlays; }; 89 | 90 | in 91 | {} 92 | 93 | ``` 94 | 95 | or by setting the `packageOverrides` attribute of the config element. 96 | 97 | ```nix 98 | 99 | let 100 | overridez = import ./nix/haskell-overridez.nix; 101 | config = { 102 | packageOverrides = pkgs: { 103 | haskellPackages = pkgs.haskellPackages.override { 104 | overrides = overridez.allIn ./nix; 105 | }; 106 | }; 107 | }; 108 | pkgs = import { inherit config; }; 109 | 110 | in 111 | {} 112 | 113 | ``` 114 | 115 | Some overrides can't be specified using the features of `haskell-overridez` and need to be specified directly. These direct overrides can be combined with the configured ones using `combineAllIn` instead of `allIn`: 116 | 117 | ```nix 118 | 119 | let 120 | overridez = import ./nix/haskell-overridez.nix; 121 | myManualOverride = self: super: {}; 122 | myImportedOverrides = import /from/some/nix/file.nix; 123 | 124 | overlays = [ 125 | (newPkgs: oldPkgs: { 126 | haskellPackages = oldPkgs.haskellPackages.override { 127 | overrides = overridez.combineAllIn ./nix [myManualOverride myImportedOverrides]; 128 | }; 129 | }) 130 | ]; 131 | pkgs = import { inherit overlays; }; 132 | 133 | in 134 | {} 135 | 136 | 137 | ``` 138 | 139 | ### Using the library functions in reflex-project-skeleton projects 140 | 141 | Projects developed using the [Reflex Platform](https://github.com/reflex-frp/reflex-platform) can benefit from adopting the layout in 142 | [reflex-project-skeleton](https://github.com/ElvishJerricco/reflex-project-skeleton). This allows them to share 143 | haskell code between frontend and backend. In these projects, `haskell-overridez` can be used as follows: 144 | 145 | ```nix 146 | 147 | let pkgs = import {}; 148 | overridez = import ./nix/haskell-overridez.nix; 149 | in 150 | 151 | {}: 152 | 153 | (import ../../repos/reflex-platform {}).project ({ pkgs, ... }: { 154 | packages = { 155 | common = ./common; 156 | backend = ./backend; 157 | frontend = ./frontend; 158 | }; 159 | 160 | shells = { 161 | ghc = ["common" "backend" "frontend"]; 162 | ghcjs = ["common" "frontend"]; 163 | }; 164 | 165 | overrides = overridez.allIn ./nix; 166 | }) 167 | 168 | ``` 169 | 170 | ## Fetching shared configs 171 | 172 | `haskell-overridez` has a `fetch` subcommand that makes it easy to share the overrides it manages. As long as the override config files are saved in a git repository, they can be fetched for use in other projects. 173 | `haskell-overridez fetch` copies the override configuration from a target git repo to a subdirectory of the current project's `nix` directory. 174 | 175 | ### Sharing public projects 176 | 177 | - Use `haskell-overridez` to manage the `nix` overrides of a project 178 | - Publish the project to an online git repo, ensuring that the `nix` folder is a top-level directory in the repo 179 | - Use `haskell-overridez fetch ` to clone the project's nix configs 180 | 181 | #### Fetch configs from private git clones 182 | 183 | To fetch from local private git repos, use a [file url][] to the git directory. 184 | 185 | #### Examples 186 | 187 | - [This example repo][] can have its configs fetched. 188 | - See the integration test fixtures for examples of [remote fetching][] and [local fetching][], and for usage of [a remote-fetched config][] and of [a local-fetched config][]. 189 | 190 | [This example repo]: https://github.com/adetokunbo/example-fetched-haskell-overridez 191 | [file url]: https://en.wikipedia.org/wiki/File_URI_scheme 192 | [remote fetching]: https://github.com/adetokunbo/haskell-overridez/blob/8c18163683145f11fdf37b9ee85860452f2ea057/fixtures/ichibanme-no-yagai-purojekuto/setup_test.sh 193 | [local fetching]: https://github.com/adetokunbo/haskell-overridez/blob/8c18163683145f11fdf37b9ee85860452f2ea057/fixtures/sanbanme-no-yagai-purojekuto/setup_test.sh 194 | [a remote-fetched config]: https://github.com/adetokunbo/haskell-overridez/blob/8c18163683145f11fdf37b9ee85860452f2ea057/fixtures/ichibanme-no-yagai-purojekuto/default.nix 195 | [a local-fetched config]: https://github.com/adetokunbo/haskell-overridez/blob/8c18163683145f11fdf37b9ee85860452f2ea057/fixtures/sanbanme-no-yagai-purojekuto/default.nix 196 | 197 | ## Contributions 198 | 199 | Contributions are welcome! Please raise an [issue](https://github.com/adetokunbo/haskell-overridez/issues) to report any problems or [open a PR](https://github.com/adetokunbo/haskell-overridez/pulls) with fixes and improvements. 200 | 201 | ## Versioning 202 | 203 | `haskell-overridez` uses [PVP][]. While it does not provide a library, the package provides an executable and nixpkg functions. Its __public API__ is defined as the documentation provided by `haskell-overridez -h` and all the nixpkgs functions exported by `default.nix`. 204 | 205 | [PVP]: http://pvp.haskell.org 206 | 207 | ### Updating after releases 208 | 209 | Each 'version' tag (e.g, vN.N.N) in the repository is a release. To update managed projects to a new release 210 | 211 | - re-install `haskell-overridez` 212 | - update the projects to use the releases's nixpkgs functions with `haskell-overridez -i` 213 | 214 | #### Newer projects 215 | 216 | These are installed using a versioned archive file, so updating is optional. If you don't upgrade, any existing projects will be unaffected. 217 | 218 | #### Older projects 219 | 220 | These were installed with the original installation instructions that used an archive of the master branch. Unfortunately, after each new release, the hash of the master branch changes, meaning that the hash specified in `/nix/haskell-overridez.nix` of these projects becomes incorrect, and derivations using the overrides will start to fail to load. In these cases, you __must__ update `haskell-overridez` and the affected projects. 221 | 222 | 223 | ## Road Map 224 | 225 | 1. Ask people to try it out to see if its useful ([reddit](https://www.reddit.com/r/haskell/comments/8k9g08/a_tool_that_helps_automate_the_installation_and/?ref=share&ref_source=link)) 226 | 2. Iterate on any proposed feature requests (.. ongoing) 227 | 3. (??) Merge it into [nixpkgs](https://github.com/NixOS/nixpkgs) (later, if people think that's a good idea) 228 | 229 | ## License 230 | BSD-3 clause 231 | -------------------------------------------------------------------------------- /build.nix: -------------------------------------------------------------------------------- 1 | { system ? builtins.currentSystem 2 | , nixBase ? "18.09" 3 | }: 4 | let 5 | pkgsMake = import ./nix/fetchPkgsMake.nix {}; 6 | nixVersion = import (./. + "/nix/${nixBase}.nix"); 7 | nixpkgs = import ./nix/fetchNixPkgs.nix nixVersion; 8 | pkgsMakeArgs = { 9 | nixpkgsRev = nixVersion.rev; 10 | nixpkgsSha256 = nixVersion.sha256; 11 | haskellArgs = { 12 | envMoreTools = [ 13 | pkgs.haskellPackages.apply-refact 14 | pkgs.haskellPackages.cabal2nix 15 | pkgs.haskellPackages.cabal-install 16 | pkgs.haskellPackages.ghcid 17 | pkgs.haskellPackages.hlint 18 | pkgs.haskellPackages.hoogle 19 | pkgs.haskellPackages.stylish-cabal 20 | pkgs.haskellPackages.stylish-haskell 21 | ]; 22 | }; 23 | }; 24 | pkgs = import nixpkgs { inherit system; }; 25 | 26 | in 27 | 28 | pkgsMake pkgsMakeArgs ({ call, lib, ... }: rec { 29 | haskell-overridez-exe = call.haskell.cabal2nix.app ./.; 30 | haskell-overridez = call.package ./nix/wrapper; 31 | }) 32 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { debug ? false, pkgs ? import {} }: 2 | let 3 | lib = import ./lib.nix { inherit debug pkgs; }; 4 | build = import ./build.nix {}; 5 | in 6 | { 7 | inherit (build) haskell-overridez; 8 | inherit (lib) allIn combineAllIn nixExprIn gitJsonIn optionsIn; 9 | } 10 | -------------------------------------------------------------------------------- /exe/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DeriveGeneric #-} 2 | {-# LANGUAGE DuplicateRecordFields #-} 3 | {-# LANGUAGE FlexibleContexts #-} 4 | {-# LANGUAGE LambdaCase #-} 5 | {-# LANGUAGE NamedFieldPuns #-} 6 | {-# LANGUAGE OverloadedStrings #-} 7 | {-# LANGUAGE QuasiQuotes #-} 8 | module Main (main) where 9 | 10 | import Control.Monad (join, void) 11 | import Control.Monad.Catch (MonadMask, bracket) 12 | import Data.Bifunctor (first) 13 | 14 | import Data.Function (on) 15 | import Data.List.NonEmpty (toList) 16 | import Data.Maybe (catMaybes, listToMaybe) 17 | import Data.Text (Text) 18 | import qualified Data.Text as Text 19 | import Data.Version (showVersion) 20 | import GHC.Generics 21 | import Paths_haskell_overridez (version) 22 | import Prelude hiding (FilePath) 23 | 24 | import Control.Monad.Managed (managed, runManaged) 25 | import qualified Data.Aeson as Aeson 26 | import Data.Aeson.Casing 27 | import Filesystem.Path (directory, filename) 28 | import Filesystem.Path.CurrentOS hiding (empty) 29 | import NeatInterpolation 30 | import Network.URI (URI (..), parseURI, uriRegName) 31 | import qualified Options.Applicative as Options 32 | import Turtle hiding (text) 33 | import qualified Turtle (text) 34 | 35 | -- Imports that allow the implementation of the json methods 36 | import Control.Foldl (Fold, FoldM (..)) 37 | import qualified Control.Foldl as Foldl 38 | import qualified Data.Aeson.Parser as Aeson 39 | import qualified Data.Attoparsec.ByteString as A 40 | import qualified Data.ByteString as ByteString 41 | import qualified Data.Text.Encoding as Text 42 | 43 | -- Accessing information in cabal files 44 | import Distribution.Pretty (Pretty, prettyShow) 45 | import Distribution.Text (simpleParse) 46 | import qualified Distribution.Text as DistText 47 | import Distribution.Types.PackageId (PackageIdentifier (..)) 48 | import Distribution.Types.Version (Version, nullVersion) 49 | 50 | data Options 51 | = Fetch 52 | { _target :: Text -- ^ the git repo to download from 53 | , _subpath :: Maybe FilePath -- ^ the directory in the repo containing the config 54 | , _revision :: Maybe Text -- ^ the target revision 55 | , _hash :: Maybe Text -- ^ the hash at the target revision 56 | } 57 | | Delete Text -- ^ Specifies an override to be deleted 58 | | List -- ^ List the current overrides 59 | | Initialize -- ^ Initialize (or re-initialize) a project using overrides 60 | | Add -- ^ Add an override 61 | { _asJson :: Bool -- ^ Save it as github json 62 | , _target :: Text -- ^ Name of the target override 63 | , _args :: [Text] -- ^ Additional args for the downloading the target 64 | , _cabalOpts :: [CabalOpt] -- ^ Cabal option override 65 | } deriving Show 66 | 67 | 68 | cmdlineWithVersion :: Options.Parser (Options, Maybe FilePath) 69 | cmdlineWithVersion = 70 | Options.infoOption 71 | (showVersion version) 72 | (Options.long "version" 73 | <> Options.short 'v' 74 | <> Options.help "Show the version of haskell-overridez") 75 | <*> cmdlineParser 76 | 77 | cmdlineParser :: Parser (Options, Maybe FilePath) 78 | cmdlineParser 79 | = (,) 80 | <$> 81 | ((subcommand "fetch" "Fetches overrides from a git repo" 82 | (Fetch 83 | <$> argText "target" "The url hosting the shared config." 84 | <*> optional (optPath "subpath" 'd' 85 | "the subdirectory of the git repo that contains the config") 86 | <*> optional (argText "revision" "The git revision to download from") 87 | <*> optional (argText "hash" 88 | "When specified, the hash is used to verify the contents of the repo"))) 89 | <|> (Delete <$> optText "delete" 'd' "Deletes the overrides for a package.") 90 | <|> Options.flag' List ( 91 | Options.long "list" 92 | <> Options.short 'l' 93 | <> Options.help "List the overridden packages in the project") 94 | <|> Options.flag' Initialize 95 | (Options.long "initialize" 96 | <> Options.short 'i' 97 | <> Options.help 98 | "Reinitialize the project. This adds the file \ 99 | \ `nix/haskell-overridez.nix` to the project if it is not present\ 100 | \ or updates it to reflect the current version of\ 101 | \ haskell-overiddez. This file simplifies the\ 102 | \ import of the haskell-overridez nixpkgs functions") 103 | <|> 104 | (Add 105 | <$> switch "github" 'g' 106 | "Save github json describing the package git repo instead of a nix expr.\ 107 | \ TARGET is required to be . If an additional\ 108 | \ argument is given, it is treated as the git revision to be downloaded" 109 | <*> argText "target" 110 | "The target package. Unless the --github flag is specified, this\ 111 | \ is any target url that the cabal2nix command understand." 112 | <*> many (argText "additional args" 113 | "Unless --github is specified, these are additional args\ 114 | \ to pass on to cabal2nix; use -- to precede any options")) 115 | <*> many (Options.option Options.auto ( 116 | Options.long "flag-override" 117 | <> Options.metavar "FLAG_OVERRIDES" 118 | <> Options.help 119 | "Cabal flag overrides to include in the package override\ 120 | \ specification ")) 121 | ) 122 | <*> 123 | optional ( 124 | optPath "project-dir" 'o' 125 | "the target directory. It defaults to the current working directory.") 126 | 127 | -- | Represents the information obtained from running nix-prefetch-git. 128 | data PrefetchInfo = 129 | PrefetchInfo 130 | { _pfUrl :: Text 131 | , _pfRev :: Text 132 | , _pfSha256 :: Text 133 | } deriving (Show, Generic) 134 | 135 | instance Aeson.FromJSON PrefetchInfo where 136 | parseJSON = Aeson.genericParseJSON $ aesonPrefix snakeCase 137 | 138 | mainSummary :: Description 139 | mainSummary = 140 | "Adds override files to the nix subdirectory of a project\n\n\ 141 | \The files are either the 'prefetch' json or the nix expression\n\ 142 | \output of cabal2nix describing the target haskell package.\ \\n\n\ 143 | \These files are used by the functions of the accompanying\n\ 144 | \nix-expr library to create an override function that\n\ 145 | \combines all the specified overrides." 146 | 147 | main :: IO () 148 | main = options mainSummary cmdlineWithVersion >>= runCmd 149 | 150 | runCmd :: (Options, Maybe FilePath) -> IO () 151 | runCmd (List, wd) = inOtherCwd wd $ listOverrides 152 | runCmd ((Delete p), wd) = inOtherCwd wd $ removePackage p 153 | runCmd (Initialize, wd) = inOtherCwd wd $ initializeProject True 154 | 155 | runCmd (Add {_asJson, _target, _args, _cabalOpts}, wd) 156 | | _asJson = inOtherCwd wd $ saveGitJson _target _args _cabalOpts 157 | | otherwise = case parsePkgId _target of 158 | Nothing -> inOtherCwd wd $ saveNixExpr _target _args _cabalOpts 159 | Just pkgId -> inOtherCwd wd $ saveFromPkgId pkgId _args _cabalOpts 160 | 161 | runCmd (Fetch {_target, _subpath, _revision, _hash}, wd) = 162 | let 163 | fpLine = maybe "" id . textToLine . format fp 164 | matchRoot = Turtle.text . (flip (<>) "/") . format fp 165 | dropRoot dir = sed (matchRoot dir *> return "") 166 | grepOverridez dir = dropRoot dir 167 | $ grep allOverridezPat $ fpLine <$> lstree dir 168 | fromTextStr = fromText . Text.pack 169 | fetchPathOf aUrl 170 | | uriScheme aUrl == "file:" = fileURIPath aUrl 171 | | otherwise = authPath aUrl <$> uriAuthority aUrl 172 | fileURIPath aUrl = 173 | Just $ "nix" "localhost" (filename $ fromTextStr $ uriPath aUrl) 174 | authPath aUrl a = "nix" 175 | (fromTextStr $ uriRegName a) 176 | (fromTextStr $ tail $ uriPath aUrl) 177 | -- appendSubpath dir = Just $ maybe dir (() dir) _subpath 178 | in 179 | case ((parseURI $ Text.unpack _target) >>= fetchPathOf) of 180 | Nothing -> die $ format ("not a valid target uri: "%s%"") _target 181 | (Just dst) -> do 182 | cwd <- pwd 183 | let dst' = (maybe cwd id wd) dst 184 | sh $ do 185 | tmp <- using (mktempdir "/tmp" "hozfetch") 186 | sh $ saveRemoteRepo tmp _target _revision _hash 187 | let src = maybe tmp (flip () tmp) _subpath 188 | fold (grepOverridez src) Foldl.list >>= \case 189 | [] -> die $ format ("no config found at "%s%"") _target 190 | zs -> cpTo dst' src $ (fromText . lineToText) <$> select zs 191 | 192 | setAllHashesMsg :: Text -> Text 193 | setAllHashesMsg name = 194 | format ("\nCannot handle "%s%"\n") name 195 | <> format (" Please set the environment variable "%s%"") allHashesEnv 196 | <> ".\n This should be the path to a nix data derivation containing\ 197 | \ the hashes and cabal files for all packages on hackage.\n Its\ 198 | \ contents are required to correctly resolve cabal:// urls. \ 199 | \ When haskell-overridez is installed using nix, this environment\ 200 | \ variable is set automatically.\n" 201 | 202 | -- | Save a nix expression file for a package specified by its 'PackageIdentifier'. 203 | saveFromPkgId :: PackageIdentifier -> [Text] -> [CabalOpt] -> IO () 204 | saveFromPkgId pkgId extraArgs cabalOpts = do 205 | let whenAllHashes = flip $ maybe $ die $ setAllHashesMsg $ prettyShow' pkgId 206 | hs <- lookupEnv allHashesEnv 207 | whenAllHashes hs $ \allHashes' -> do 208 | pkg <- findPackage pkgId $ inproc "tar" ["tzvf", allHashes'] empty 209 | cwd <- pwd 210 | runManaged $ do 211 | untarDir <- using (mktempdir cwd "hoz-untar") 212 | cwd' <- managed (withOtherCwd $ Just untarDir) 213 | procs "tar" ["xvf", allHashes', pkg] empty 214 | 215 | -- needed because cabal2nix examines a cache in $HOME for local 216 | -- packages, when run from a nix-shell this breaks as $HOME is reset to 217 | -- a directory that does not exist 218 | export "HOME" $ format fp untarDir 219 | 220 | _ <- managed (withOtherCwd $ Just cwd') 221 | saveNixExpr (format fp untarDir <> "/" <> pkg) extraArgs cabalOpts 222 | 223 | 224 | -- | Save a nix expression file in the current project by shelling out to 225 | -- cabal2nix. 226 | saveNixExpr :: MonadIO io => Text -> [Text] -> [CabalOpt] -> io () 227 | saveNixExpr url extraArgs cabalOpts = do 228 | let findPname = findNixField "pname" 229 | shCmd = lineToText <$> inproc "cabal2nix" ([url] <> extraArgs) empty 230 | (mbPackage, lines_) <- fold shCmd findPname 231 | case mbPackage of 232 | Nothing -> 233 | die $ format ("could not find a package name in the output of"%s%"") url 234 | (Just p) -> do 235 | let dstText = format ("nix/nix-expr/"%s%".nix") p 236 | dst = fromText dstText 237 | mktree (directory dst) 238 | output dst $ shTextToLines $ select lines_ 239 | initializeProject False 240 | addConfiguredOptions cabalOpts $ unsafeTextToLine p 241 | cwd <- format fp <$> pwd 242 | printf ("saved nix-expr for "%s%" to "%s%" in "%s%"\n") p dstText cwd 243 | 244 | -- | Save a package as a JSON descriptor of its github repository. 245 | saveGitJson :: MonadIO io => Text -> [Text] -> [CabalOpt] -> io () 246 | saveGitJson userRepo [] cabalOpts = saveGitJson userRepo [""] cabalOpts 247 | saveGitJson userRepo (revision : _xs) cabalOpts = do 248 | let target = format ("https://github.com/"%s%".git") userRepo 249 | just z = if z == "" then Nothing else Just z 250 | defPkgName = snd $ Text.breakOnEnd "/" userRepo 251 | liftIO $ runManaged $ do 252 | tmp <- using (mktempdir "/tmp" "hoz-json") 253 | sh $ saveRemoteRepo tmp target (just revision) Nothing 254 | pkgName <- pkgNameOrDef tmp defPkgName 255 | let dstText = format ("nix/git-json/"%s%".json") pkgName 256 | dst = fromText dstText 257 | mktree (directory dst) 258 | cp (tmp <> githubJsonPath) dst 259 | addConfiguredOptions cabalOpts $ unsafeTextToLine pkgName 260 | initializeProject False 261 | cwd <- format fp <$> pwd 262 | printf ("saved git json for "%s%" to "%s%" in "%s%"\n") pkgName dstText cwd 263 | 264 | -- | Determine the package name from the contents of the project directory or 265 | -- uses the provided default value. 266 | pkgNameOrDef :: MonadIO io => FilePath -> Text -> io Text 267 | pkgNameOrDef dir def = do 268 | fromDir <- do 269 | fromNix <- pkgNameFromNix dir 270 | fromCabal <- pkgNameFromCabal dir 271 | return $ fromNix <|> fromCabal 272 | case fromDir of 273 | Nothing -> do 274 | liftIO $ do 275 | echo "*warning* could not package name in a cabal or default.nix file" 276 | printf ("*warning* - defaulting to "%s%"\n") def 277 | echo "*warning* Files examined are:" 278 | view $ format fp <$> ls dir 279 | return def 280 | Just pkg -> return pkg 281 | 282 | -- | Determine the package name by examining the default.nix file in the project 283 | -- directory if that is present. 284 | pkgNameFromNix :: MonadIO io => FilePath -> io (Maybe Text) 285 | pkgNameFromNix projDir = do 286 | let nixPath = projDir <> "nix/default.nix" 287 | findPname = findNixField "pname" 288 | liftIO $ testfile nixPath >>= \case 289 | False -> return Nothing 290 | True -> fst <$> fold (lineToText <$> input nixPath) findPname 291 | 292 | -- | Determine the package name by examining the cabal file in the project 293 | -- directory if that is present. 294 | pkgNameFromCabal :: MonadIO io => FilePath -> io (Maybe Text) 295 | pkgNameFromCabal projDir = do 296 | let fs = grepText (suffix ".cabal") (format fp <$> ls projDir) 297 | names = sed findName $ grep findName $ join $ (input . fromText) <$> fs 298 | findName = do 299 | void $ "name:" <|> "Name:" 300 | void $ spaces1 301 | name <- plus anyChar 302 | return name 303 | fold names Foldl.list >>= \case 304 | [z] -> return $ Just $ lineToText z 305 | _ -> return Nothing 306 | 307 | -- | Initialize the current project. 308 | initializeProject :: MonadIO io => Bool -> io () 309 | initializeProject always = do 310 | uninitialized <- testfile loaderPath 311 | when (always || not uninitialized) $ do 312 | hash <- single (inshell computeLoaderHashCmd empty) 313 | let nixExp = computeLoaderContent archiveUrl $ lineToText hash 314 | output loaderPath $ select $ textToLines nixExp 315 | 316 | -- | Add any configured options for a package. 317 | addConfiguredOptions :: MonadIO io => [CabalOpt] -> Line -> io () 318 | addConfiguredOptions cabalOpts pkgName = 319 | mapM_ (addLine pkgName . configPath) cabalOpts 320 | 321 | -- | Remove the override configuration for a package from the current project. 322 | removePackage :: Text -> IO () 323 | removePackage package = do 324 | let nixExpr = fromText $ "nix/nix-expr/" <> package <> ".nix" 325 | gitJson = fromText $ "nix/git-json/" <> package <> ".json" 326 | rmWhenPresent f' = testfile f' >>= (flip when $ rm f') 327 | rmFromFile = removeLine package 328 | rmWhenPresent nixExpr 329 | rmWhenPresent gitJson 330 | mapM_ (rmFromFile . configPath) [minBound .. maxBound] 331 | 332 | -- | List the overrides configured in the current project. 333 | listOverrides :: IO () 334 | listOverrides = do 335 | let dropExt ext = sedSuffix $ ext *> "" 336 | matchRoot = Turtle.text . (flip (<>) "/") . format fp 337 | dropRoot dir = sed (matchRoot dir *> return "") 338 | fpLine = maybe "" id . textToLine . format fp 339 | lsNoPrefix dir = dropRoot dir $ fpLine <$> ls dir 340 | list' title dir ext = do 341 | exists <- testdir dir 342 | when exists $ stdout $ title <|> "" <|> (dropExt ext $ lsNoPrefix dir) 343 | list' "Nix exprs" "nix/nix-expr" ".nix" 344 | stdout (return "") 345 | list' "Github json" "nix/git-json" ".json" 346 | 347 | -- | Change the current working directory while performing an action. 348 | -- 349 | -- Similar to 'inOtherCwd', but can be used with 'managed' 350 | withOtherCwd 351 | :: (MonadIO io, MonadMask io) 352 | => Maybe FilePath 353 | -> (FilePath -> io a) -> io a 354 | withOtherCwd Nothing action = pwd >>= action 355 | withOtherCwd (Just dst) action = 356 | let 357 | switchd = pwd >>= (\cwd -> cd dst >> showDir dst >> return cwd) 358 | showDir = printf ("working dir is now "%fp%"\n") 359 | in 360 | bracket (liftIO switchd) (liftIO . cd) action 361 | 362 | -- | Change the current working directory while performing an action. 363 | inOtherCwd :: (MonadIO io, MonadMask io) => Maybe FilePath -> io a -> io a 364 | inOtherCwd mbDir action = withOtherCwd mbDir $ const action 365 | 366 | saveRemoteRepo :: FilePath 367 | -> Text 368 | -> Maybe Text 369 | -> Maybe Text 370 | -> Shell Text 371 | saveRemoteRepo dst target (Just rev) (Just hash) = do 372 | lineToText <$> inproc "nix-prefetch-git" 373 | [ "--quiet" 374 | , "--builder" 375 | , "--out" 376 | , format fp dst 377 | , target 378 | , rev 379 | , hash 380 | ] empty 381 | 382 | saveRemoteRepo dst target (Just rev) Nothing = do 383 | let jsonOut = dst <> githubJsonPath 384 | output jsonOut $ inproc "nix-prefetch-git" [ target , rev ] empty 385 | info <- liftIO $ json $ lineToText <$> input jsonOut 386 | saveRemoteRepo dst target (Just $ _pfRev info) (Just $ _pfSha256 info) 387 | 388 | saveRemoteRepo dst target _ _ = 389 | saveRemoteRepo dst target (Just "") Nothing 390 | 391 | 392 | findPackage :: PackageIdentifier -> Shell Line -> IO Text 393 | findPackage pkgId@PackageIdentifier{pkgName, pkgVersion} xs = do 394 | maxVersion <- fold withVersions $ Foldl.maximumBy (compare `on` snd) 395 | case maxVersion of 396 | Nothing -> die $ missingErr $ prettyShow' pkgId 397 | Just (_, Nothing) -> die $ missingErr $ prettyShow' pkgId 398 | Just (package, _) -> return package 399 | where 400 | missingErr = format ("could not find package\ 401 | \: "%s%" in nix's all-cabal-hashes tar file") 402 | withVersions 403 | = (fmap pairWithVersion) 404 | . (fmap lineToText) 405 | . sed baseName 406 | $ grepPkg xs 407 | grepPkg = grep $ has $ Turtle.text search 408 | 409 | pairWithVersion z = (z, listToMaybe $ catMaybes $ match extractVersion z) 410 | extractVersion = do 411 | void $ "all-cabal-hashes-" >> (selfless $ plus $ noneOf "/") 412 | void $ "/" 413 | pname <- selfless $ plus $ noneOf "/" 414 | void $ "/" 415 | pversion <- selfless $ plus $ noneOf "/" 416 | void $ "/" 417 | void $ selfless $ star anyChar 418 | return $ parseVersion $ format (""%s%"-"%s%"") pname pversion 419 | 420 | baseName = do 421 | void $ selfless $ star anyChar 422 | start <- "all-cabal-hashes-" 423 | rest <- star anyChar 424 | pure $ start <> rest 425 | 426 | search = if pkgVersion == nullVersion 427 | then format ("/"%s%".cabal") name' 428 | else format ("/"%s%"/"%s%"/"%s%".cabal") name' version' name' 429 | where 430 | name' = prettyShow' pkgName 431 | version' = prettyShow' pkgVersion 432 | 433 | {- | Decode JSON text into aeson's 'Aeson.Value'. Invalid JSON values are 434 | implicitly discarded. 435 | >>> view $ json $ select ["{ \"ke", "y\": [", " 1] }[", "]1"] 436 | Object (fromList [("key",Array [Number 1.0])]) 437 | Array [] 438 | Number 1.0 439 | >>> view $ json $ select ["][]"] 440 | Array [] 441 | -} 442 | jsonValue :: Shell Text -> Shell Aeson.Value 443 | jsonValue someText = Shell _foldIO' 444 | where 445 | _foldIO' (FoldShell step begin done) = foldIO someText 446 | (Foldl.premapM (return . Text.encodeUtf8) (FoldM step' begin' done')) 447 | where 448 | step' (z, r) bs = case A.feed r bs of 449 | A.Fail leftover _ _ -> 450 | step' (z, r0) (ByteString.drop 1 leftover) 451 | r'@(A.Partial {}) -> return (z, r') 452 | r'@(A.Done leftover val) -> do 453 | z' <- step z val 454 | if ByteString.null leftover 455 | then return (z', r') 456 | else step' (z', r0) leftover 457 | begin' = return (begin, r0) 458 | done' (z, r) = case r of 459 | A.Partial {} -> do 460 | (z', _) <- step' (z, r) "" 461 | done z' 462 | _ -> done z 463 | r0 = A.Partial (A.parse Aeson.value) 464 | 465 | -- | Parses data directly from a 'Shell' 'Text'. 466 | -- 467 | -- It dies if the data cannot be parsed. 468 | json :: Aeson.FromJSON a => Shell Text -> IO a 469 | json someText = singleJson someText >>= checkResult 470 | where 471 | singleJson = single . (fmap Aeson.fromJSON) . jsonValue 472 | checkResult = \case 473 | (Aeson.Success a) -> return a 474 | (Aeson.Error badParse) -> do 475 | let msg = format ("json': parse failed: "%s%"") errText 476 | errText = Text.pack badParse 477 | die msg 478 | 479 | -- | Copy all the relative paths specified by targets under root to the 480 | -- destination. 481 | cpTo :: MonadIO io => FilePath -> FilePath -> Shell FilePath -> io () 482 | cpTo dst dstRoot targets = sh $ do 483 | t <- targets 484 | let newt = fromText $ Text.replace "nix/" "" $ format fp t 485 | newPath = dst newt 486 | oldPath = dstRoot t 487 | mktree (directory newPath) 488 | cp oldPath newPath 489 | liftIO $ printf ("copied "%fp%" to "%fp%"\n") oldPath newPath 490 | 491 | -- | Creates a 'Fold' which searches some 'Text' for a nix field with the given 492 | -- name. 493 | findNixField :: Text -> Fold Text ((Maybe Text), [Text]) 494 | findNixField name = (,) <$> findNixField' <*> Foldl.list 495 | where 496 | findNixField' = Fold foldFunc Nothing id 497 | foldFunc = mkStepFunc $ nixField name 498 | mkStepFunc origF = f' 499 | where f' Nothing z = origF z 500 | f' y _ = y 501 | nixField nm nms = 502 | let findValue = do 503 | void $ spaces1 504 | void $ Turtle.text nm 505 | void " = \"" 506 | value <- selfless (plus (noneOf "\"")) 507 | void $ "\"" 508 | return value 509 | in listToMaybe $ match (prefix findValue) nms 510 | 511 | -- | Attempts to parse the input as a cabal uri: cabal://. 512 | parsePkgId :: Text -> Maybe PackageIdentifier 513 | parsePkgId uri = 514 | let findPkgId = do 515 | void $ "cabal://" 516 | pkgId <- (star anyChar) 517 | return $ simpleParse' pkgId 518 | in join $ listToMaybe $ match (findPkgId) uri 519 | 520 | -- | A 'Pattern' that matches any file the could have been created by the 521 | -- haskell-overridez tool. 522 | allOverridezPat :: Pattern Text 523 | allOverridezPat = Foldl.fold (Fold (<|>) empty id) 524 | ([ suffix ("nix/nix-expr/" <> notSlashes <> ".nix") 525 | , suffix ("nix/git-json/" <> notSlashes <> ".json") 526 | ] <> map (suffix . Turtle.text . optionsPath) knownCabalOpts) 527 | where 528 | optionsPath = ((<>) "nix/options/") . firstLower . Text.pack . show 529 | notSlashes = selfless (plus (noneOf "/")) 530 | 531 | -- | The supported cabal option overrides. 532 | data CabalOpt = 533 | DoJailbreak 534 | | DontCheck 535 | | DontHaddock 536 | deriving (Eq, Read, Show, Enum, Bounded) 537 | 538 | -- | The supported cabal option overrides. 539 | knownCabalOpts :: [CabalOpt] 540 | knownCabalOpts = [minBound .. maxBound] 541 | 542 | -- | Determine the path of the configuration file for a 'CabalOpt'. 543 | configPath :: CabalOpt -> FilePath 544 | configPath = fromText . ((<>) "nix/options/") . firstLower . Text.pack . show 545 | 546 | -- | Lowercase the first character of some text. 547 | firstLower :: Text -> Text 548 | firstLower = uncurry (<>) . first Text.toLower . Text.splitAt 1 549 | 550 | -- | Remove a line from a file if it is present. 551 | removeLine :: Text -> FilePath -> IO () 552 | removeLine someText src = do 553 | exists <- testfile src 554 | when exists $ do 555 | initial <- fold (input src) Foldl.list 556 | let allow = (/=) someText . lineToText 557 | output src $ mfilter allow $ select initial 558 | 559 | -- | Add a line to a text file if it is not already present. 560 | addLine :: MonadIO io => Line -> FilePath -> io () 561 | addLine aLine p = liftIO $ testfile p >>= \case 562 | False -> mktree (directory p) >> (output p $ return aLine) 563 | _ -> do 564 | initial <- fold (input p) Foldl.list 565 | output p $ uniq $ (select initial) <|> return aLine 566 | 567 | shTextToLines :: Shell Text -> Shell Line 568 | shTextToLines = join . fmap (select . toList . textToLines) 569 | 570 | prettyShow' :: Pretty a => a -> Text 571 | prettyShow' = Text.pack . prettyShow 572 | 573 | simpleParse' :: DistText.Text a => Text -> Maybe a 574 | simpleParse' = simpleParse . Text.unpack 575 | 576 | parseVersion :: Text -> Maybe Version 577 | parseVersion = (fmap pkgVersion) . simpleParse' 578 | 579 | lookupEnv :: MonadIO io => Text -> io (Maybe Text) 580 | lookupEnv name = env >>= (return . lookup name) 581 | 582 | allHashesEnv :: Text 583 | allHashesEnv = "HOZ_ALL_CABAL_HASHES" 584 | 585 | -- | The path of the haskell-overridez nix-expr library loader. 586 | loaderPath :: FilePath 587 | loaderPath = "nix/haskell-overridez.nix" 588 | 589 | -- | The path to save prefetch github json metadata 590 | githubJsonPath :: FilePath 591 | githubJsonPath = "github.json" 592 | 593 | currentVersion, archiveUrlPrefix, archiveUrl, archiveUrlSuffix :: Text 594 | archiveUrlPrefix = "https://github.com/adetokunbo/haskell-overridez/archive/v" 595 | archiveUrlSuffix = ".tar.gz" 596 | currentVersion = Text.pack $ showVersion version 597 | archiveUrl = archiveUrlPrefix <> currentVersion <> archiveUrlSuffix 598 | 599 | -- | The command used to compute the hash of the library loader git repository. 600 | computeLoaderHashCmd :: Text 601 | computeLoaderHashCmd = "nix-prefetch-url --unpack " <> archiveUrl 602 | 603 | -- | Generate the content of the library loader nix-expr file. 604 | computeLoaderContent :: Text -> Text -> Text 605 | computeLoaderContent tarUrl h = [text| 606 | let 607 | pkgs = import {}; 608 | overridez = fetchTarball { 609 | url = "$tarUrl"; 610 | sha256 = "$h"; 611 | }; 612 | in 613 | import overridez { inherit pkgs; } 614 | |] 615 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from nix-exprs created by cabal2nix with github https uris 2 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | foldl = null; 6 | managed = null; 7 | optparse-applicative = null; 8 | turtle = null; 9 | gobanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/gobanme-no-purojekuto.nix {}; 10 | }; 11 | in [ 12 | (newPkgs: oldPkgs: 13 | let 14 | inherit (oldPkgs.lib) composeExtensions fold; 15 | composeExtensionsList = fold composeExtensions (_: _: {}); 16 | in { 17 | haskellPackages = oldPkgs.haskellPackages.override { 18 | overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; 19 | }; 20 | }) 21 | ]; 22 | pkgs = import { inherit overlays; }; 23 | in 24 | { gobanme-no-purojekuto = pkgs.haskellPackages.gobanme-no-purojekuto; 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/gobanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: gobanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable gobanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD --flag-override DontCheck https://github.com/pcapriotti/optparse-applicative 9 | $HOZ_TEST_CMD --flag-override DoJailbreak https://github.com/Gabriel439/Haskell-Turtle-Library 10 | $HOZ_TEST_CMD --flag-override DoJailbreak https://github.com/Gabriel439/Haskell-Foldl-Library 11 | $HOZ_TEST_CMD --flag-override DoJailbreak https://github.com/Gabriel439/Haskell-Managed-Library 12 | 13 | popd > /dev/null 14 | } 15 | 16 | setup_test 17 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from config fetched from a subpath of a github repository 2 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | githubKara = overridez.allIn ./nix/github.com/adetokunbo/example-fetched-haskell-overridez/subdir-root/a-subdir; 4 | overlays = 5 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 6 | foldl = null; 7 | managed = null; 8 | optparse-applicative = null; 9 | turtle = null; 10 | gobanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/gobanme-no-yagai-purojekuto.nix {}; 11 | }; 12 | in [ 13 | (newPkgs: oldPkgs: 14 | let 15 | inherit (oldPkgs.lib) composeExtensions fold; 16 | composeExtensionsList = fold composeExtensions (_: _: {}); 17 | in { 18 | haskellPackages = oldPkgs.haskellPackages.override { 19 | overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [githubKara])]; 20 | }; 21 | }) 22 | ]; 23 | pkgs = import { inherit overlays; }; 24 | in 25 | { gobanme-no-yagai-purojekuto = pkgs.haskellPackages.gobanme-no-yagai-purojekuto; 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/gobanme-no-yagai-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: gobanme-no-yagai-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable gobanme-no-yagai-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/gobanme-no-yagai-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD fetch --subpath subdir-root/a-subdir https://github.com/adetokunbo/example-fetched-haskell-overridez 9 | 10 | popd > /dev/null 11 | } 12 | 13 | setup_test 14 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from nix-exprs created by cabal2nix with github https uris saved in a specific directory 2 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | jibunNo = import ./nix/indirect_import.nix; 4 | overlays = 5 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 6 | foldl = null; 7 | managed = null; 8 | optparse-applicative = null; 9 | turtle = null; 10 | hachibanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/hachibanme-no-purojekuto.nix {}; 11 | }; 12 | in [ 13 | (newPkgs: oldPkgs: 14 | let 15 | inherit (oldPkgs.lib) composeExtensions fold; 16 | composeExtensionsList = fold composeExtensions (_: _: {}); 17 | in { 18 | haskellPackages = oldPkgs.haskellPackages.override { 19 | overrides = composeExtensionsList [dropTestPkgs jibunNo]; 20 | }; 21 | }) 22 | ]; 23 | pkgs = import { inherit overlays; }; 24 | in 25 | { hachibanme-no-purojekuto = pkgs.haskellPackages.hachibanme-no-purojekuto; 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/hachibanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: hachibanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable hachibanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/hachibanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | local cwd=$(pwd) 8 | local test_name="${cwd##*/}" 9 | 10 | # Make a directory under the tmp root in which to save the output 11 | local dst_dir="${HOZ_TMP_DIR}/dst/${test_name}" 12 | mkdir -p $dst_dir 13 | 14 | # Set up the configuration 15 | $HOZ_TEST_CMD --flag-override DontCheck -o $dst_dir https://github.com/pcapriotti/optparse-applicative 16 | $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Turtle-Library 17 | $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Foldl-Library 18 | $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Managed-Library 19 | 20 | (cat < ./nix/indirect_import.nix 27 | 28 | popd > /dev/null 29 | } 30 | 31 | setup_test 32 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from config fetched from a github repository 2 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | githubKara = overridez.allIn ./nix/github.com/adetokunbo/example-fetched-haskell-overridez; 4 | overlays = 5 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 6 | foldl = null; 7 | managed = null; 8 | optparse-applicative = null; 9 | turtle = null; 10 | ichibanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/ichibanme-no-yagai-purojekuto.nix {}; 11 | }; 12 | in [ 13 | (newPkgs: oldPkgs: 14 | let 15 | inherit (oldPkgs.lib) composeExtensions fold; 16 | composeExtensionsList = fold composeExtensions (_: _: {}); 17 | in { 18 | haskellPackages = oldPkgs.haskellPackages.override { 19 | overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [githubKara])]; 20 | }; 21 | }) 22 | ]; 23 | pkgs = import { inherit overlays; }; 24 | in 25 | { ichibanme-no-yagai-purojekuto = pkgs.haskellPackages.ichibanme-no-yagai-purojekuto; 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/ichibanme-no-yagai-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: ichibanme-no-yagai-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable ichibanme-no-yagai-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/ichibanme-no-yagai-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD fetch https://github.com/adetokunbo/example-fetched-haskell-overridez 9 | 10 | popd > /dev/null 11 | } 12 | 13 | setup_test 14 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | saves recognized options when saving nix exprs or github json 2 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | foldl = null; 6 | managed = null; 7 | optparse-applicative = null; 8 | turtle = null; 9 | jyuubanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/jyuubanme-no-purojekuto.nix {}; 10 | }; 11 | in [ 12 | (newPkgs: oldPkgs: 13 | let 14 | inherit (oldPkgs.lib) composeExtensions fold; 15 | composeExtensionsList = fold composeExtensions (_: _: {}); 16 | in { 17 | haskellPackages = oldPkgs.haskellPackages.override { 18 | overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; 19 | }; 20 | }) 21 | ]; 22 | pkgs = import { inherit overlays; }; 23 | in 24 | { jyuubanme-no-purojekuto = pkgs.haskellPackages.jyuubanme-no-purojekuto; 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/jyuubanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: jyuubanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable jyuubanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD --flag-override DontCheck cabal://optparse-applicative-0.14.2.0 9 | 10 | $HOZ_TEST_CMD --flag-override DontHaddock cabal://foldl-1.4.5 11 | 12 | $HOZ_TEST_CMD --flag-override DontCheck --flag-override DontHaddock --flag-override DoJailbreak -g Gabriel439/Haskell-Turtle-Library 13 | 14 | $HOZ_TEST_CMD -g Gabriel439/Haskell-Managed-Library 15 | 16 | popd > /dev/null 17 | } 18 | 19 | setup_test 20 | -------------------------------------------------------------------------------- /fixtures/jyuubanme-no-purojekuto/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | test() { 5 | local nonOptions=("ignore" "andIgnore" "reallyIgnore") 6 | local v 7 | for v in "${nonOptions[@]}" 8 | do 9 | local option_file="nix/options/${v}" 10 | [[ -f "$option_file" ]] && { 11 | echo "Fail: found a config file for unrecognized option '$v'" 12 | return 1 13 | } 14 | done 15 | 16 | _has_config "dontCheck" "optparse-applicative turtle" 17 | _has_config "doJailbreak" "foldl turtle" 18 | _has_config "dontHaddock" "foldl turtle" 19 | } 20 | 21 | _has_config() { 22 | local option=${1:-''} 23 | local pkgs=${2:-''} 24 | [[ -z $pkgs ]] && return 1; 25 | 26 | local option_file="nix/options/${option}" 27 | [[ -f "$option_file" ]] || { 28 | echo "Fail: expected a config file for option $option; it's missing" 29 | echo 30 | ls -lR nix 31 | return 1 32 | } 33 | local p 34 | for p in $pkgs 35 | do 36 | grep -q $p $option_file || { 37 | echo "Fail: expected $option_file to contain $p" 38 | return 1 39 | } 40 | done 41 | } 42 | 43 | test 44 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | the requested options are applied to the resulting nix derivation 2 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | foldl = null; 6 | managed = null; 7 | optparse-applicative = null; 8 | turtle = null; 9 | jyuuichibanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/jyuuichibanme-no-purojekuto.nix {}; 10 | }; 11 | in [ 12 | (newPkgs: oldPkgs: 13 | let 14 | inherit (oldPkgs.lib) composeExtensions fold; 15 | composeExtensionsList = fold composeExtensions (_: _: {}); 16 | in { 17 | haskellPackages = oldPkgs.haskellPackages.override { 18 | overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; 19 | }; 20 | }) 21 | ]; 22 | pkgs = import { inherit overlays; }; 23 | in 24 | { jyuuichibanme-no-purojekuto = pkgs.haskellPackages.jyuuichibanme-no-purojekuto; 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/jyuuichibanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: jyuuichibanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable jyuuichibanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_wo_options() { 5 | # Save the configuration without options 6 | $HOZ_TEST_CMD https://github.com/pcapriotti/optparse-applicative 7 | $HOZ_TEST_CMD https://github.com/Gabriel439/Haskell-Turtle-Library 8 | $HOZ_TEST_CMD https://github.com/Gabriel439/Haskell-Foldl-Library 9 | $HOZ_TEST_CMD https://github.com/Gabriel439/Haskell-Managed-Library 10 | } 11 | 12 | setup_with_options() { 13 | local cwd=$(pwd) 14 | local test_name="${cwd##*/}" 15 | 16 | # Set up the configuration with options 17 | 18 | # Make a directory under the tmp root in which to save the config with options 19 | local dst_dir="${HOZ_TMP_DIR}/dst/${test_name}" 20 | mkdir -p $dst_dir 21 | 22 | # Save the configuration 23 | $HOZ_TEST_CMD --flag-override DontCheck -o $dst_dir https://github.com/pcapriotti/optparse-applicative 24 | $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Turtle-Library 25 | $HOZ_TEST_CMD --flag-override DontHaddock -o $dst_dir https://github.com/Gabriel439/Haskell-Foldl-Library 26 | $HOZ_TEST_CMD --flag-override DontHaddock -o $dst_dir https://github.com/Gabriel439/Haskell-Managed-Library 27 | 28 | (cat < ./nix/indirect_import.nix 35 | } 36 | 37 | setup_test() { 38 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 39 | pushd $this_dir > /dev/null 40 | local cwd=$(pwd) 41 | local test_name="${cwd##*/}" 42 | setup_wo_options 43 | setup_with_options 44 | popd 45 | } 46 | 47 | setup_test 48 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | _check_is_different() { 5 | local search=${1:-''} 6 | local refs1=${2:-''} 7 | local refs2=${3:-''} 8 | [[ -z $refs2 ]] && return 1 9 | 10 | found1=$(grep -h $search $refs1) 11 | found2=$(grep -h $search $refs2) 12 | [[ $found1 == $found2 ]] && { 13 | echo 14 | printf "FAIL: expected runtime refs for $search to differ\n but '$found1' == '$found2'\n" 15 | return 1 16 | } 17 | echo 18 | printf "OK: runtime refs for $search differ:\n '$found1' != '$found2'\n" 19 | } 20 | 21 | test() { 22 | local cwd=$(pwd) 23 | local test_name="${cwd##*/}" 24 | 25 | # without options 26 | echo 27 | echo "instantiating the derivation without options" 28 | drv_wo_opts=$(nix-instantiate -A $test_name default.nix) 29 | echo "without options: derivation $drv_wo_opts" 30 | wo_opts=$(mktemp -q) 31 | nix-store -q --references $drv_wo_opts > $wo_opts 32 | cat $wo_opts 33 | 34 | # with options 35 | echo 36 | echo "instantiating the derivation with options" 37 | drv_with_opts=$(nix-instantiate -A $test_name with-options.nix) 38 | echo "without options: derivation $drv_with_opts" 39 | with_opts=$(mktemp -q) 40 | nix-store -q --references $drv_with_opts > $with_opts 41 | cat $with_opts 42 | 43 | # confirm the runtime references for the dependencies are different derivations 44 | _check_is_different "foldl" $wo_opts $with_opts 45 | _check_is_different "turtle" $wo_opts $with_opts 46 | } 47 | 48 | test 49 | -------------------------------------------------------------------------------- /fixtures/jyuuichibanme-no-purojekuto/with-options.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | jibunNo = import ./nix/indirect_import.nix; 4 | config = { 5 | packageOverrides = pkgs: 6 | let 7 | inherit (pkgs.lib) composeExtensions fold; 8 | composeExtensionsList = fold composeExtensions (_: _: {}); 9 | dropTestPkgs = self: super: { 10 | foldl = null; 11 | managed = null; 12 | optparse-applicative = null; 13 | turtle = null; 14 | jyuuichibanme-no-purojekuto = self.callPackage ./nix/jyuuichibanme-no-purojekuto.nix {}; 15 | }; 16 | in { 17 | haskellPackages = pkgs.haskellPackages.override { 18 | overrides = composeExtensionsList [dropTestPkgs jibunNo]; 19 | }; 20 | }; 21 | }; 22 | pkgs = import { inherit config; }; 23 | in 24 | { jyuuichibanme-no-purojekuto = pkgs.haskellPackages.jyuuichibanme-no-purojekuto; 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from nix-exprs created by cabal2nix on a subdirectory of a github https repository 2 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE FlexibleContexts #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | {-# LANGUAGE MultiParamTypeClasses #-} 4 | {-# LANGUAGE OverloadedStrings #-} 5 | {-# LANGUAGE StandaloneDeriving #-} 6 | 7 | module Main where 8 | 9 | import Control.Monad.Log 10 | import Data.Text.Prettyprint.Doc (Doc) 11 | import System.IO (stdout) 12 | 13 | main :: IO () 14 | main = 15 | withFDHandler defaultBatchingOptions stdout 0.4 80 $ \logToStdout -> 16 | runLoggingT testApp (logToStdout . renderWithSeverity id) 17 | 18 | 19 | testApp :: MonadLog (WithSeverity (Doc ann)) m => m () 20 | testApp = do 21 | logMessage (WithSeverity Informational "Don't mind me") 22 | logMessage (WithSeverity Error "But do mind me!") 23 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | beam-core = null; 6 | kyuubanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/kyuubanme-no-purojekuto.nix {}; 7 | }; 8 | in [ 9 | (newPkgs: oldPkgs: 10 | let 11 | inherit (oldPkgs.lib) composeExtensions fold; 12 | composeExtensionsList = fold composeExtensions (_: _: {}); 13 | in { 14 | haskellPackages = oldPkgs.haskellPackages.override { 15 | overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; 16 | }; 17 | }) 18 | ]; 19 | pkgs = import { inherit overlays; }; 20 | in 21 | { kyuubanme-no-purojekuto = pkgs.haskellPackages.kyuubanme-no-purojekuto; 22 | } 23 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: kyuubanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable kyuubanme-no-purojekuto 9 | build-depends: base < 5, logging-effect, prettyprinter, text 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/kyuubanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD https://github.com/jship/logging-effect-extra -- --subpath logging-effect-extra-file 9 | 10 | popd > /dev/null 11 | } 12 | 13 | setup_test 14 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | cannot create an overlay when dependencies are removed as a control 2 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | foldl = null; 6 | managed = null; 7 | optparse-applicative = null; 8 | turtle = null; 9 | nanabanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/nanabanme-no-purojekuto.nix {}; 10 | }; 11 | in [ 12 | (newPkgs: oldPkgs: = { 13 | haskellPackages = oldPkgs.haskellPackages.override { 14 | overrides = dropTestPkgs; 15 | }; 16 | }) 17 | ]; 18 | pkgs = import { inherit overlays; }; 19 | in 20 | { nanabanme-no-purojekuto = pkgs.haskellPackages.nanabanme-no-purojekuto; 21 | } 22 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/nanabanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: nanabanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable nanabanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD --flag-override DontCheck cabal://optparse-applicative-0.14.2.0 9 | $HOZ_TEST_CMD --flag-override DoJailbreak cabal://turtle-1.5.12 10 | $HOZ_TEST_CMD --flag-override DoJailbreak cabal://foldl-1.4.5 11 | $HOZ_TEST_CMD --flag-override DoJailbreak cabal://managed-1.0.6 12 | 13 | popd > /dev/null 14 | } 15 | 16 | setup_test 17 | -------------------------------------------------------------------------------- /fixtures/nanabanme-no-purojekuto/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test() { 4 | nix-build --no-out-link || return 0 5 | test_desc="$(cat DESC)" 6 | echo 7 | echo "FAILED: '$test_desc' in $(pwd)" 8 | echo 9 | return 1 10 | } 11 | 12 | test 13 | -------------------------------------------------------------------------------- /fixtures/new_fixture_dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | new-fixture-dir() { 5 | local subst=$1 6 | local initial_prefix=${2:-'yonbanme-no'} 7 | local initial="${initial_prefix}-purojekuto" 8 | local updated="${subst}-purojekuto" 9 | 10 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 11 | cp -Rv $this_dir/$initial $this_dir/$updated 12 | mv $this_dir/$updated/{$initial,$updated}.cabal 13 | sed -i'.bak' -e "s/$initial/$updated/g" $this_dir/$updated/$updated.cabal 14 | sed -i'.bak' -e "s/$initial/$updated/g" $this_dir/$updated/default.nix 15 | rm -v $this_dir/$updated/*.bak 16 | } 17 | 18 | new-fixture-dir "$@" 19 | -------------------------------------------------------------------------------- /fixtures/nibanme-no-yagai-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | cannot fetch config files from an invalid repository 2 | -------------------------------------------------------------------------------- /fixtures/nibanme-no-yagai-purojekuto/nibanme-no-yagi-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: nibanme-no-yagai-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable nibanme-no-yagai-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/nibanme-no-yagai-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | echo "skipped setup" 6 | } 7 | 8 | setup_test 9 | -------------------------------------------------------------------------------- /fixtures/nibanme-no-yagai-purojekuto/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test() { 4 | local invalid_fetch=https://github.com/adetokunbo/automine 5 | $HOZ_TEST_CMD fetch $invalid_fetch || return 0 6 | test_desc="$(cat DESC)" 7 | echo 8 | echo "FAILED: '$test_desc'" 9 | echo 10 | return 1 11 | } 12 | 13 | test 14 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from git json created by nix-prefetch-git 2 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | foldl = null; 6 | managed = null; 7 | optparse-applicative = null; 8 | turtle = null; 9 | rokubanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/rokubanme-no-purojekuto.nix {}; 10 | }; 11 | in [ 12 | (newPkgs: oldPkgs: 13 | let 14 | inherit (oldPkgs.lib) composeExtensions fold; 15 | composeExtensionsList = fold composeExtensions (_: _: {}); 16 | in { 17 | haskellPackages = oldPkgs.haskellPackages.override { 18 | overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; 19 | }; 20 | }) 21 | ]; 22 | pkgs = import { inherit overlays; }; 23 | in 24 | { rokubanme-no-purojekuto = pkgs.haskellPackages.rokubanme-no-purojekuto; 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/rokubanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: rokubanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable rokubanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/rokubanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | # Using -g with foldl or optparse-applicative makes cabal2nix infinitely 9 | # recurse when converting the json to nix-expr 10 | $HOZ_TEST_CMD --flag-override DontCheck https://github.com/pcapriotti/optparse-applicative 11 | $HOZ_TEST_CMD --flag-override DontCheck https://github.com/Gabriel439/Haskell-Foldl-Library 12 | 13 | $HOZ_TEST_CMD --flag-override DoJailbreak -g Gabriel439/Haskell-Turtle-Library 14 | $HOZ_TEST_CMD --flag-override DoJailbreak -g Gabriel439/Haskell-Managed-Library 15 | 16 | popd > /dev/null 17 | } 18 | 19 | setup_test 20 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from config fetched from a local git repository 2 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | localhostKara = overridez.allIn ./nix/localhost/sanbanme-no-yagai-purojekuto; 4 | overlays = 5 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 6 | foldl = null; 7 | managed = null; 8 | optparse-applicative = null; 9 | turtle = null; 10 | sanbanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/sanbanme-no-yagai-purojekuto.nix {}; 11 | }; 12 | in [ 13 | (newPkgs: oldPkgs: 14 | let 15 | inherit (oldPkgs.lib) composeExtensions fold; 16 | composeExtensionsList = fold composeExtensions (_: _: {}); 17 | in { 18 | haskellPackages = oldPkgs.haskellPackages.override { 19 | overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [localhostKara])]; 20 | }; 21 | }) 22 | ]; 23 | pkgs = import { inherit overlays; }; 24 | in 25 | { sanbanme-no-yagai-purojekuto = pkgs.haskellPackages.sanbanme-no-yagai-purojekuto; 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/sanbanme-no-yagai-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: sanbanme-no-yagai-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable sanbanme-no-yagai-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/sanbanme-no-yagai-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | setup_test() { 4 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 5 | pushd $this_dir > /dev/null 6 | local cwd=$(pwd) 7 | local out_dir="${HOZ_TMP_DIR}/${cwd##*/}" 8 | mkdir -p $out_dir 9 | 10 | # fetch a recent version of the github example, save it locally, and use 11 | # that as a local git repo (needs all the flags belows; plus the revision and hash) 12 | nix-prefetch-git --quiet \ 13 | --out $out_dir \ 14 | --builder \ 15 | --leave-dotGit \ 16 | https://github.com/adetokunbo/example-fetched-haskell-overridez \ 17 | e1dc13ae7dcb3a4c4b7f426a94ecf523532ea574 \ 18 | 0sapkc9mpk95dlq6n87z8xa8w4r0cnxxpnyp971m5phjpbn83c7q 19 | ls -l $out_dir 20 | 21 | $HOZ_TEST_CMD fetch "file://${out_dir}" 22 | popd > /dev/null 23 | } 24 | 25 | setup_test 26 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from nix-exprs created by cabal2nix with cabal:// uris 2 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | overlays = 4 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 5 | foldl = null; 6 | managed = null; 7 | optparse-applicative = null; 8 | turtle = null; 9 | yonbanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/yonbanme-no-purojekuto.nix {}; 10 | }; 11 | in [ 12 | (newPkgs: oldPkgs: 13 | let 14 | inherit (oldPkgs.lib) composeExtensions fold; 15 | composeExtensionsList = fold composeExtensions (_: _: {}); 16 | in { 17 | haskellPackages = oldPkgs.haskellPackages.override { 18 | overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; 19 | }; 20 | }) 21 | ]; 22 | pkgs = import { inherit overlays; }; 23 | in 24 | { yonbanme-no-purojekuto = pkgs.haskellPackages.yonbanme-no-purojekuto; 25 | } 26 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | 8 | $HOZ_TEST_CMD --flag-override DontCheck cabal://optparse-applicative-0.14.2.0 9 | $HOZ_TEST_CMD --flag-override DoJailbreak cabal://turtle-1.5.12 10 | $HOZ_TEST_CMD --flag-override DoJailbreak cabal://foldl-1.4.5 11 | $HOZ_TEST_CMD --flag-override DoJailbreak cabal://managed-1.0.6 12 | 13 | popd > /dev/null 14 | } 15 | 16 | setup_test 17 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-purojekuto/yonbanme-no-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: yonbanme-no-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable yonbanme-no-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/.gitignore: -------------------------------------------------------------------------------- 1 | nix 2 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/DESC: -------------------------------------------------------------------------------- 1 | create an overlay from config fetched from a local git repository in a specific directory 2 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Timothy Emiola 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Main where 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | overridez = import ./nix/haskell-overridez.nix; 3 | localhostKara = import ./nix/indirect_import.nix; 4 | overlays = 5 | let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { 6 | foldl = null; 7 | managed = null; 8 | optparse-applicative = null; 9 | turtle = null; 10 | yonbanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/yonbanme-no-yagai-purojekuto.nix {}; 11 | }; 12 | in [ 13 | (newPkgs: oldPkgs: 14 | let 15 | inherit (oldPkgs.lib) composeExtensions fold; 16 | composeExtensionsList = fold composeExtensions (_: _: {}); 17 | in { 18 | haskellPackages = oldPkgs.haskellPackages.override { 19 | overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [localhostKara])]; 20 | }; 21 | }) 22 | ]; 23 | pkgs = import { inherit overlays; }; 24 | in 25 | { yonbanme-no-yagai-purojekuto = pkgs.haskellPackages.yonbanme-no-yagai-purojekuto; 26 | } 27 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/setup_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | setup_test() { 5 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 6 | pushd $this_dir > /dev/null 7 | local cwd=$(pwd) 8 | local test_name="${cwd##*/}" 9 | local out_dir="${HOZ_TMP_DIR}/${test_name}" 10 | mkdir -p $out_dir 11 | 12 | # fetch the recent version of the github example, save it locally, and use 13 | # that as a local git repo (needs all the flags belows; plus the revision and hash) 14 | nix-prefetch-git --quiet \ 15 | --out $out_dir \ 16 | --builder \ 17 | --leave-dotGit \ 18 | https://github.com/adetokunbo/example-fetched-haskell-overridez \ 19 | e1dc13ae7dcb3a4c4b7f426a94ecf523532ea574 \ 20 | 0sapkc9mpk95dlq6n87z8xa8w4r0cnxxpnyp971m5phjpbn83c7q 21 | ls -l $out_dir 22 | 23 | # Make a directory under the tmp root in which to save the output 24 | local dst_dir="${HOZ_TMP_DIR}/dst/${test_name}" 25 | mkdir -p $dst_dir 26 | (cat < ./nix/indirect_import.nix 33 | $HOZ_TEST_CMD -o $dst_dir fetch "file://${out_dir}" 34 | [[ -d $dst_dir ]] && ls -l $dst_dir 35 | popd > /dev/null 36 | } 37 | 38 | setup_test 39 | -------------------------------------------------------------------------------- /fixtures/yonbanme-no-yagai-purojekuto/yonbanme-no-yagai-purojekuto.cabal: -------------------------------------------------------------------------------- 1 | name: yonbanme-no-yagai-purojekuto 2 | version: 1.0.0 3 | license: BSD3 4 | license-file: LICENSE 5 | cabal-version: >= 1.18 6 | build-type: Simple 7 | 8 | executable yonbanme-no-yagai-purojekuto 9 | build-depends: base < 5, foldl, text, turtle 10 | main-is: Main.hs 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /haskell-overridez.cabal: -------------------------------------------------------------------------------- 1 | name: haskell-overridez 2 | version: 0.10.3.1 3 | synopsis: Manage nix overrides for haskell packages 4 | description: A tool to simplify the use of nix overrides during haskell development 5 | license: BSD3 6 | license-file: LICENSE 7 | author: Tim Emiola 8 | maintainer: tim.emiola@gmail.com 9 | category: Distribution,nix 10 | homepage: https://github.com/adetokunbo/haskell-overridez 11 | bug-reports: https://github.com/adetokunbo/haskell-overridez/issues 12 | build-type: Simple 13 | extra-source-files: README.md 14 | ChangeLog.md 15 | cabal-version: 2.0 16 | 17 | source-repository head 18 | type: git 19 | location: https://github.com/adetokunbo/haskell-overridez.git 20 | 21 | executable haskell-overridez 22 | main-is: Main.hs 23 | other-modules: Paths_haskell_overridez 24 | autogen-modules: Paths_haskell_overridez 25 | hs-source-dirs: exe 26 | build-depends: base >= 4.2 && < 5 27 | , Cabal >= 2.2.0.1 28 | , aeson >= 1.2.4.0 29 | , aeson-casing >= 0.1 && < 0.3 30 | , attoparsec >= 0.13.2 && < 0.15 31 | , bytestring >= 0.10.8 && < 0.13 32 | , exceptions >= 0.8.3 33 | , foldl >= 1.4 && < 1.5 34 | , managed >= 1.0.6 && < 1.2 35 | , neat-interpolation >= 0.3.2 && < 0.5 36 | , network-uri >= 2.6.1.0 && < 2.8 37 | , optparse-applicative >= 0.14.2 && < 0.16 38 | , system-fileio == 0.3.16.3 39 | , system-filepath == 0.4.14 40 | , text >= 1.2.3 && < 1.3 41 | , turtle >= 1.5.7 && < 1.6 42 | default-language: Haskell2010 43 | ghc-options: -Wall -fwarn-tabs 44 | -------------------------------------------------------------------------------- /lib.nix: -------------------------------------------------------------------------------- 1 | { debug ? false, pkgs ? import {} }: 2 | let inherit (pkgs.lib) composeExtensions fold foldr listToAttrs mapAttrs'; 3 | inherit (builtins) fromJSON match pathExists readFile readDir replaceStrings toPath trace; 4 | 5 | composeExtensionsList = fold composeExtensions (_: _: {}); 6 | isDir = path: pathExists (toPath (toString (path + "/."))); 7 | _trace = msg: result: if debug then (trace msg result) else result; 8 | in 9 | rec { 10 | combineAllIn = rootDir: otherOverrides: 11 | let 12 | extDir = d: (toString rootDir) + "/" + d; 13 | allExtensions = [ 14 | (nixExprIn (extDir "nix-expr")) 15 | (gitJsonIn (extDir "git-json")) 16 | (optionsIn (extDir "options")) 17 | ] ++ otherOverrides; 18 | in 19 | composeExtensionsList allExtensions; 20 | 21 | allIn = rootDir: combineAllIn rootDir []; 22 | 23 | nixExprIn = aDir: self: super: 24 | let 25 | mkOverride = f: self.callPackage (aDir + "/${f}") { }; 26 | toPackage = f: _: _trace "found override (nix-expr): ${f}" rec { 27 | name = builtins.replaceStrings [ ".nix" ] [ "" ] f; 28 | value = _trace ("using override (nix-expr): ${name}") (mkOverride f); 29 | }; 30 | in 31 | if isDir aDir 32 | then mapAttrs' toPackage (readDir (toPath aDir)) 33 | else _trace ("no overrides (nix-expr): directory not found ${aDir}") {}; 34 | 35 | gitJsonIn = aDir: self: super: 36 | let 37 | inherit (pkgs) fetchFromGitHub; 38 | inherit (pkgs.lib) zipListsWith; 39 | 40 | toGithubAttrs = src: 41 | let ownerRepo = match "https://github.com/(.*)/(.*)\.git" src.url; 42 | zipNV = zipListsWith (fst: snd: {name = fst; value = snd; }); 43 | ownerRepoAttrs = listToAttrs (zipNV ["owner" "repo"] ownerRepo); 44 | in { inherit (src) rev sha256; } // ownerRepoAttrs; 45 | 46 | applyFuncs = funcs: pkgName: foldr (g: a: g a) pkgName funcs; 47 | 48 | readDirOverrides = fetcher: toFetchAttrs: d: 49 | let filePath = n: d + "/${n}.json"; 50 | loadFuncs = [fetcher toFetchAttrs fromJSON readFile filePath]; 51 | mkOverride = n: self.callCabal2nix n (applyFuncs loadFuncs n) { }; 52 | toPackage = file: _: _trace "found override (git-json): ${file}" rec { 53 | name = replaceStrings [ ".json" ] [ "" ] file; 54 | value = _trace ("using override (git-json): ${name}") (mkOverride name); 55 | }; 56 | in mapAttrs' toPackage (readDir d); 57 | 58 | in 59 | if isDir aDir 60 | then readDirOverrides fetchFromGitHub toGithubAttrs aDir 61 | else _trace ("no overrides (git-json): was not a dir ${aDir}") {}; 62 | 63 | optionsIn = aDir: self: super: 64 | let 65 | inherit (builtins) attrValues filter intersectAttrs isList split; 66 | inherit (pkgs.lib) mapAttrs; 67 | 68 | supportedOptions = { 69 | doJailbreak = pkgs.haskell.lib.doJailbreak; 70 | dontCheck = pkgs.haskell.lib.dontCheck; 71 | dontHaddock = pkgs.haskell.lib.dontHaddock; 72 | }; 73 | 74 | mkOverrides = option: names: _: super: 75 | let 76 | f = supportedOptions.${option}; 77 | toPackage = name: _trace "found override (options): ${toString name}" { 78 | inherit name; 79 | value = _trace ("using override (options): ${toString name}") (f super.${name}); 80 | }; 81 | in 82 | _trace "found option ${option} on pkgs ${toString names}" 83 | listToAttrs (map toPackage names); 84 | 85 | readOptionsOverrides = d: 86 | let 87 | nonEmptyNonList = x: (!(isList x)) && x != ""; 88 | availableOptions = intersectAttrs (readDir d) supportedOptions; 89 | lines = f: filter nonEmptyNonList (split "\n" (readFile (d + "/${f}"))); 90 | namesPerOption = mapAttrs (opt: _: lines opt) availableOptions; 91 | optionsOverrides = attrValues (mapAttrs mkOverrides namesPerOption); 92 | in 93 | (composeExtensionsList optionsOverrides) self super; 94 | in 95 | if isDir aDir 96 | then readOptionsOverrides aDir 97 | else _trace ("no overrides (options): was not a dir ${aDir}") {}; 98 | } -------------------------------------------------------------------------------- /nix/18.09.nix: -------------------------------------------------------------------------------- 1 | { 2 | rev = "a4c4cbb613cc3e15186de0fdb04082fa7e38f6a0"; 3 | sha256 = "1lagfycy2lvfc8cdxk98dz2rxjlrbmv9hj42x0x40sy66bck1w0y"; 4 | } -------------------------------------------------------------------------------- /nix/fetchNixPkgs.nix: -------------------------------------------------------------------------------- 1 | { rev # The Git revision of nixpkgs to fetch 2 | , sha256 # The SHA256 of the downloaded data 3 | }: 4 | builtins.fetchTarball { 5 | url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; 6 | inherit sha256; 7 | } 8 | -------------------------------------------------------------------------------- /nix/fetchPkgsMake.nix: -------------------------------------------------------------------------------- 1 | { # The defaulted revision of the pkgsMake repo 2 | pkgsMakeRev ? "fff811a6d5aa386e835168e5f7b3dfca81b5c910" 3 | 4 | # The SHA256 of the repo at pkgsMakeRev 5 | , pkgsMakeSha256 ? "0mbvmmza58frrj4cqs9ky2bwgw3z6wkpb8d8k1911g11rapl7wgq" 6 | }: 7 | let 8 | pkgsMakePath = (import {}).fetchFromGitHub { 9 | owner = "shajra"; 10 | repo = "example-nix"; 11 | rev = pkgsMakeRev; 12 | sha256 = pkgsMakeSha256; 13 | }; 14 | in 15 | import pkgsMakePath 16 | -------------------------------------------------------------------------------- /nix/wrapper/default.nix: -------------------------------------------------------------------------------- 1 | { all-cabal-hashes 2 | , cabal2nix 3 | , gnugrep 4 | , gnused 5 | , haskellPackages 6 | , makeWrapper 7 | , nix-prefetch-scripts 8 | , stdenv 9 | }: 10 | 11 | stdenv.mkDerivation rec { 12 | name = "haskell-overridez"; 13 | version = haskellPackages.haskell-overridez-exe.version; 14 | unpackPhase = "true"; 15 | nativeBuildInputs = [ makeWrapper ]; 16 | buildCommand = '' 17 | mkdir -p $out/bin 18 | makeWrapper ${haskellPackages.haskell-overridez-exe}/bin/haskell-overridez $out/bin/haskell-overridez \ 19 | --prefix PATH : ${stdenv.lib.makeBinPath ([ cabal2nix gnugrep gnused nix-prefetch-scripts ])} \ 20 | --set HOME /homeless-shelter \ 21 | --set HOZ_ALL_CABAL_HASHES ${all-cabal-hashes} 22 | ''; 23 | 24 | meta = haskellPackages.haskell-overridez-exe.meta; 25 | } -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | (import ./build.nix {}).env.haskell.withEnvTools (pkgs: [ ]) 2 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | test() { 5 | [[ -n ${HOZ_TEST_DEBUG:-''} ]] && set -x 6 | HOZ_TMP_DIR=$(mktemp -d) 7 | trap "rm -fR $HOZ_TMP_DIR" INT TERM EXIT 8 | 9 | # set up the HOZ_TEST_CMD to point at the haskell-overridez built by 10 | # the nix-build 11 | local test_descs=() 12 | local skipped_descs=() 13 | local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") 14 | pushd $this_dir 15 | nix-build --show-trace build.nix 16 | export HOZ_TEST_CMD=$(pwd)/result/bin/haskell-overridez 17 | popd 18 | 19 | fixture_dir=$this_dir/fixtures 20 | local test_dirs="$@" 21 | [[ $# == 0 ]] && test_dirs=$(ls $fixture_dir) 22 | for d in $test_dirs 23 | do 24 | local test_dir=${fixture_dir}/${d} 25 | [[ -d $test_dir ]] || continue 26 | 27 | pushd $test_dir > /dev/null 28 | # maybe skip 29 | [[ -f ./SKIP ]] && { 30 | local reason=$(cat ./SKIP) 31 | local cause="${reason:-'uncompleted test'}" 32 | local skipped_desc="$cause (in $test_dir)" 33 | skipped_descs+=("$skipped_desc") 34 | echo 35 | echo "SKIPPED: $skipped_desc" 36 | echo 37 | popd > /dev/null 38 | continue 39 | } 40 | 41 | local test_desc="project: $test_dir" 42 | [[ -f ./DESC ]] && test_desc="$(cat DESC) (in $test_dir)" 43 | test_descs+=("$test_desc") 44 | echo 45 | echo "testing: ${test_desc}" 46 | echo 47 | _test_one_project $test_dir 48 | echo 49 | echo "OK: ${test_desc}" 50 | 51 | popd > /dev/null 52 | done 53 | 54 | echo 55 | echo "tested haskell-overridez v$($HOZ_TEST_CMD -v | head -n 1)" 56 | echo "completed: ${#test_descs[@]} integration tests, skipped ${#skipped_descs[@]}" 57 | if (( ${#test_descs[@]} != 0 )) 58 | then 59 | for test_desc in "${test_descs[@]}" 60 | do 61 | echo "OK: ${test_desc}" 62 | done 63 | fi 64 | [[ -n ${HOZ_TEST_DEBUG:-''} ]] && set +x || return 0 65 | } 66 | 67 | _test_one_project() { 68 | local test_dir=${1-''} 69 | [[ -z $test_dir ]] && return 1; 70 | 71 | # setup 72 | _prepare_nix_dir 73 | _add_current_project_to_nix 74 | source setup_test.sh 75 | 76 | # test, defaulting 'nix-build' 77 | [[ -f test.sh ]] && source test.sh || nix-build --no-out-link --show-trace 78 | 79 | # cleanup if the debug flag is not set 80 | [[ -d nix ]] && [[ -z ${HOZ_TEST_DEBUG:-''} ]] && rm -fR nix || return 0 81 | } 82 | 83 | _prepare_nix_dir() { 84 | [[ -d nix ]] && rm -fR nix 85 | mkdir -p nix 86 | (cat < {}; 89 | in 90 | import (../../..) { inherit pkgs; } 91 | EOF 92 | ) > "nix/haskell-overridez.nix" 93 | } 94 | 95 | _add_current_project_to_nix() { 96 | local cwd=$(pwd) 97 | local nix_file="./nix/${cwd##*/}.nix" 98 | cabal2nix . > $nix_file 99 | sed -i'.bak' -e 's|src = ./.|src = ../.|' $nix_file 100 | } 101 | 102 | test "$@" 103 | --------------------------------------------------------------------------------