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

Template request: an isolated project #59

Open
woile opened this issue Jan 14, 2023 · 1 comment
Open

Template request: an isolated project #59

woile opened this issue Jan 14, 2023 · 1 comment

Comments

@woile
Copy link

woile commented Jan 14, 2023

I think it would be very useful to have a general template where people can add their dependencies and run nix develop (or whatever command is needed to open my shell with the new apps). With some documentation on how to use it on the flake itself.

I would like to initialize a flake, add packages like nixpkgs.git nixpkgs.grep nixpkgs.sed nixpkgs.redis mygithubdependency.app. And finally run a command and have the shell with those deps, this way people using my project could run the scripts of whatever I've configured. I tried the different templates but I couldn't do it, I find very hard to achieve this 😅

I think maybe one of the hardest parts for me is to import another flake on github. This would be useful to import other projects in my projects.

Thanks!

@woile
Copy link
Author

woile commented Jan 14, 2023

I think I've figured it out:

/*
  This flake provides a shell where you can add flakes

  Adding dependencies:
    1. Add your flake repository as an input url
    2. Add the repository name to the function signature
    3. Add your repo's package to buildInputs

  Opening shell with your deps:
    ```sh
    nix develop
    ```

  For compatibility with nix-shell add the template compat:
    ```sh
    nix flake new . -t templates#compat
    ```
*/
{
  description = "Build your shell";
  inputs = {
    utils = { url = "github:numtide/flake-utils"; };
    wpa_passphrase_rs = { url = "github:woile/wpa_passphrase_rs/main"; };
    # point 1: add repo url
  };
  # point 2: add to function
  outputs = { self, nixpkgs, utils, wpa_passphrase_rs }:
    utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
      in
      {
        devShell = with pkgs; mkShell {
          # point 3: add package
          buildInputs = [
            gnugrep
            gnused
            wpa_passphrase_rs.defaultPackage.${system}
          ];
        };
      }
    );
}

I can normally install using github:woile/wpa_passphrase_rs#wpa_passphrase. How would I do it here? doing wpa_passphrase.wpa_passphrase doesn't seem to work. But it does work with defaultPackage.

Would you be interested in adding a template like this?

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

No branches or pull requests

1 participant