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

@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.

@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.

lib/types.nix Outdated Show resolved Hide resolved
@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
@Lassulus
Copy link
Member Author

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

@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