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

Add --no-submodules option to suppress fetching submodules (e.g. git). #370

Merged
merged 3 commits into from Aug 13, 2018
Merged

Conversation

kquick
Copy link
Contributor

@kquick kquick commented Aug 10, 2018

There are times when submodule fetching is unnecessary (e.g. the submodules will be built as separate nix packages), so it would be nice to suppress this for git repos with extensive or recursive submodules. This patch leaves the default behavior to fetch the submodules, but adds an option to disable that.

$ diff <(time cabal2nix https://github.com/GaloisInc/macaw-semmc --subpath macaw-semmc 2> /dev/null) \
       <(time cabal2nix https://github.com/GaloisInc/macaw-semmc --subpath macaw-semmc --no-submodules 2> /dev/null)

real    0m2.169s
user    0m0.105s
sys     0m0.037s

real    1m16.636s
user    0m6.695s
sys     0m1.449s
11c11
<     sha256 = "16gmdhxn92qxpqlx2p2bd4cg1zpjsv5qa8hf4riymsifndrfcnvx";
---
>     sha256 = "0yc5y9vcvkri2cj5mma37jca07srlm8h089pqrq9zh9g63aa1b9w";
$

@kquick
Copy link
Contributor Author

kquick commented Aug 10, 2018

The travis failure is an hlint suggestion which results in more obscure usage, IMHO, so I will change this if you would like, but I think it's clearer in the current form.

fetchers :: Source -> MaybeT IO (DerivationSource, a)
fetchers source = msum . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)
[ (False, "url", [])
, (True, "git", ["--fetch-submodules"])
, (True, "git", if s then ["--fetch-submodules"] else [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO if you name s a bit more descriptively like optSubmodules which is also consistent with the call site then the hlint suggestion of using:

[ "--fetch-submodules" | optSubmodules ]

is quite clear and understandable. It's a bit like the optional function in Nix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good suggestion, thank you.

src/Cabal2nix.hs Outdated
@@ -90,6 +91,7 @@ options = Options
<*> optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
<*> pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
<*> strArgument (metavar "URI")
<*> flag True False (long "no-submodules" <> help "don't fetch git submodules")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last nitpick: what about naming the flag
--dont-fetch-submodules?
Since that name is more consistent with the flag we disable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally dislike the "dont" terminology which drops the apostrophe, but --do-not-fetch-submodules gets even wordier. In this case though I accede to the utility of consistency in the terminology.

@basvandijk basvandijk merged commit b8dc5b1 into NixOS:master Aug 13, 2018
@basvandijk
Copy link
Member

Thank you!

@kquick kquick deleted the nosub branch August 15, 2018 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants