Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental support for git dependencies #151

Merged
merged 19 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Available options:
Available commands:
init Initialize a Nix project. Existing files won't be
modified.
add Add dependency
add Add a GitHub dependency
show
update Update dependencies
modify Modify dependency
Expand All @@ -226,11 +226,11 @@ Examples:
niv add NixOS/nixpkgs-channels -n nixpkgs -b nixos-19.03
niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip

Usage: niv add [-n|--name NAME] PACKAGE ([-a|--attribute KEY=VAL] |
Usage: niv add PACKAGE [-n|--name NAME] ([-a|--attribute KEY=VAL] |
[-s|--string-attribute KEY=VAL] | [-b|--branch BRANCH] |
[-o|--owner OWNER] | [-r|--repo REPO] | [-v|--version VERSION] |
[-t|--template URL] | [-T|--type TYPE])
Add dependency
Add a GitHub dependency

Available options:
-n,--name NAME Set the package name to <NAME>
Expand All @@ -249,6 +249,10 @@ Available options:
inferred from the suffix of the URL.
-h,--help Show this help text

Experimental commands:
git Add a git dependency. Experimental.
github Add a GitHub dependency

```

#### Update
Expand Down
5 changes: 4 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ with rec
"^src/Data/Aeson$"
"^src/Data/HashMap$"
"^src/Data/HashMap/Strict$"
"^src/Data/Text$"
"^src/Niv$"
"^src/Niv/Git$"
"^src/Niv/GitHub$"
"^src/Niv/Sources$"
"^src/Niv/Update$"
Expand Down Expand Up @@ -188,7 +190,8 @@ rec
{
inherit niv niv-sdist niv-source niv-devshell niv-cabal-upload;

tests = pkgs.callPackage ./tests { inherit niv; };
tests-github = pkgs.callPackage ./tests/github { inherit niv; };
tests-git = pkgs.callPackage ./tests/git { inherit niv; };

niv-test = pkgs.runCommand "niv-test" { buildInputs = [ niv ]; }
"niv-test && touch $out";
Expand Down
6 changes: 5 additions & 1 deletion nix/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ let
else
pkgs.fetchzip { inherit (spec) url sha256; };

fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };

fetch_builtin-tarball = spec:
builtins.trace
''
Expand Down Expand Up @@ -80,10 +83,11 @@ let
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file spec
else if spec.type == "tarball" then fetch_tarball spec
else if spec.type == "git" then fetch_git spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
else if spec.type == "builtin-url" then fetch_builtin-url spec
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.fromJSON spec.type}";
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";

# Ports of functions for older nix versions

Expand Down
16 changes: 16 additions & 0 deletions src/Data/Text/Extended.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{-# LANGUAGE OverloadedStrings #-}

module Data.Text.Extended where

import Niv.Logger
import System.Exit (exitFailure)
import qualified Data.Text as T

tshow :: Show a => a -> T.Text
tshow = T.pack . show

-- not quite the perfect place for this
abort :: T.Text -> IO a
abort msg = do
tsay $ T.unwords [ tbold $ tred "FATAL:", msg ]
exitFailure
Loading