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

get nix-writers into nixpkgs #49290

Merged
merged 2 commits into from
Nov 27, 2018
Merged

get nix-writers into nixpkgs #49290

merged 2 commits into from
Nov 27, 2018

Conversation

Lassulus
Copy link
Member

@Lassulus Lassulus commented Oct 27, 2018

Get https://cgit.krebsco.de/nix-writers/about/ into nixpkgs

feedback is appreciated

stuff which still needs to be done:

  • comment all the functions in pkgs/build-support/writers.nix
  • unify interface between writeJS, writeC, writeHaskellPackage and writePerl (deps vs dependencies vs libraries)

nice to have:

  • writeHaskellPackage dependencies are attributes instead of strings
  • writeC dependencies are a list instead of attrset

Sorry, something went wrong.

@Lassulus Lassulus requested review from edolstra and nbp as code owners October 27, 2018 17:11
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation labels Oct 27, 2018
@Lassulus Lassulus force-pushed the nix-writers branch 2 times, most recently from 8a31f01 to 0b614a1 Compare October 27, 2018 17:27
@matthewbauer
Copy link
Member

I think something like this needs some good use cases to be included in full. Right now a lot of them seem like they have a pretty limited use case. I'd definitely be more comfortable with some getting included if it leads to less total code in Nixpkgs.

I had a similar try at something like writers.write in #43074. buildTree does I think the same thing so that these two are equivalent:

write "name" { "/etc/test" = { text = "hello world"; }; }
buildTree "name" {
  "/etc/test" = writeText "test" "hello world";
} {}

So I think something like that is definitely useful.

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Oct 27, 2018
@Lassulus
Copy link
Member Author

I think most of the use-cases would be outside of nixpkgs or in nixos modules.
It's very cool to have inline packages in your shell.nix or ExecStart scripts in other languages than bash.

@Lassulus Lassulus force-pushed the nix-writers branch 4 times, most recently from 31a6ec2 to 713bf87 Compare November 11, 2018 13:52
@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-linux: 1-10 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Nov 18, 2018
@GrahamcOfBorg GrahamcOfBorg removed 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation labels Nov 19, 2018
@Lassulus
Copy link
Member Author

What would be the recommended way to test these? use nixos-tests?

@Mic92
Copy link
Member

Mic92 commented Nov 23, 2018

We have pkgs/test, but maybe something in the writers directory would make more sense.

@Lassulus Lassulus changed the title WIP: get nix-writers into nixpkgs get nix-writers into nixpkgs Nov 27, 2018
@GrahamcOfBorg GrahamcOfBorg removed the 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin label Nov 27, 2018
@Lassulus
Copy link
Member Author

Soo I guess I'm done. I'm not sure about the tests though

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Reference https://github.com/krebs/nix-writers revision 40fde9e
@Mic92 Mic92 merged commit f12bd00 into NixOS:master Nov 27, 2018
@matthewbauer
Copy link
Member

matthewbauer commented Nov 28, 2018

I think we need better criteria of where this can be used. Is this intended for internal use within Nixpkgs? If so, we need some usages inside the tree. If not, why not just release this as a separate repo? I just don't think we have a good enough use for this right now.

Also, it critically doesn't support external files, which seems pretty important. You can kind of "fake" it with something like:

writeBash "examples" (builtins.readFile ./example.sh)

But this just reads the file and writes it back to the store twice! Anyway, this seems like something that is an interesting use of Nix, but should be left out of Nixpkgs.

@Lassulus
Copy link
Member Author

There are usecases inside of nixpkgs. Having something like services.xserver.windowManager.xmonad.config comes to my mind. I can implement this next. Also a lot of suckless software rely upon recompliation and there is no abstraction inside configuration.nix

About the files ending up twice in the store, does writeScript(Bin) handle this?
I guess, I could extend the writers to take strings or files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants