23:19:24 sochan | hello, i have a question about using Nix as a way to prepare a build environment for a project │
23:20:11 sochan | right now we are using a default.nix using the standard mkDerivation to prepare an environement we envoke with │
| nix-shell to work in │
23:20:15 sochan | so we can build our project │
23:20:17 sochan | https://github.com/status-im/status-react/blob/develop/default.nix │
23:20:38 sochan | but the thing is, that doesn't work for `nix build`, only for `nix-shell` │
23:20:59 sochan | because we are not trying to build our software with nix, we are just trying to prepare a build enviornment for │
| it │
23:21:39 sochan | so my question is: what is the proper way to define a build envioronement for a project without using │
| mkDerivation which makes nix think that our project is a package we are trying to build │
23:21:45 sochan | when we are not trying to build it │
23:22:35 Ralith | sochan: what I do is I have a `package.nix` which uses nixpkgs conventions and is referenced by a `shell.nix`, │
| which uses overrideAttrs to set `src = null;`, and a `default.nix` which defines a package set using │
| pkgs.lib.makeScope, imports the proper nixpkgs revision, references any other custom packages you need, etc. │
23:23:02 sochan | oh, that sounds like what we need │
23:23:14 sochan | do you maybe have an example of that somewhere on github? │
23:24:52 Ralith | no, sorry, proprietary project │
23:25:02 sochan | ah, shame │
23:25:12 sochan | i'm not that well versed in nix, but maybe I can figure it out from your comment │
23:25:32 sochan | or look for some examples of use of plg.lib.makeScope as you mentioned in some other projects on github │
23:26:04 Ralith | yeah, or grep around in nixpkgs itself for uses of it │
23:26:41 sochan | so you don't use mkDerivation at all in your default.nix? │
23:26:53 sochan | you use the makeScope method to pull in the dependencies you need │
23:27:05 sochan | and you set src to null to avoid it being built? or somthing like that? │
23:27:48 Ralith | to avoid copying the source into the nix store, which is very slow when you have a build dir floating around in │
| there for a large project and wastes space │
23:27:51 Ralith | mkDerivation is used in the package.nix │
23:28:22 Ralith | I misspoke slightly, also; the shell.nix should reference the default.nix which referencs the package.nix │
23:28:29 sochan | hmmm, how is shell.nix referenced by default.nix? or are they separate? │
23:28:31 Ralith | https://ralith.com/~ralith/pastes/prelude.nix.html is how the default.nix gets started │
23:28:47 Ralith | shell.nix references default.nix │
23:28:50 Ralith | not the other way around │
23:28:52 sochan | oh! │
23:29:23 sochan | hmmm, is it kinda like xorg? let me get the link │
23:29:43 Ralith | just `(import ./.).my-package.overrideAttrs (_: { src = null; })` or something like that │
23:29:55 sochan | https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/x11/xorg/default.nix │
23:30:01 Ralith | can throw in some extra development tools if you like too │
23:30:16 Ralith | yeah that seems like a fine example │
23:30:33 Ralith | except usually you don't inline the package expression into the file │
23:30:39 Ralith | but you can if you like, doesn't really matter │
23:30:40 sochan | righ │
23:30:45 sochan | you just callPackage │
23:30:57 sochan | from a file right? │
23:31:17 Ralith | yep, just like in all-packages.nix │
23:31:20 sochan | but anyway, this is a great start, i think you gave me a better way to do things │
23:31:27 sochan | I'll try to figure this out, thanks! I appreciate it │
23:31:44 Ralith | the prelude I pasted above lets you easily make locally modified versions too, which is handy │
23:31:46 Ralith | god luck! │
23:31:49 Ralith | good* │
23:31:58 sochan | thx!
```│
#Example
let nixpkgs = fetchTarball https://github.com/NixOS/nixpkgs/archive/6e76a618fb5d0033b06b45e64649707c6d38ddae.tar.gz; in { system ? builtins.currentSystem , config ? {}, overlays ? [] , pkgs ? (import nixpkgs { inherit system config overlays; }) }: