[RFC,1/1] nix: add a simple flake nix shell

Message ID 20231205005541.38072-1-vincenzopalazzodev@gmail.com
State Accepted
Headers
Series Improved Nix Support for GCC Development |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Vincenzo Palazzo Dec. 5, 2023, 12:55 a.m. UTC
  This commit is specifically targeting enhancements in
Nix support for GCC development. This initiative stems
from the recognized need within our community for a more
streamlined and efficient development process when using Nix.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
---
 flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 flake.nix  | 35 +++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)
 create mode 100644 flake.lock
 create mode 100644 flake.nix
  

Comments

Andrew Pinski Dec. 5, 2023, 1:02 a.m. UTC | #1
On Mon, Dec 4, 2023 at 4:58 PM Vincenzo Palazzo
<vincenzopalazzodev@gmail.com> wrote:
>
> This commit is specifically targeting enhancements in
> Nix support for GCC development. This initiative stems
> from the recognized need within our community for a more
> streamlined and efficient development process when using Nix.

I think this is wrong place for this.

>
> Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
> ---
>  flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  flake.nix  | 35 +++++++++++++++++++++++++++++++
>  2 files changed, 95 insertions(+)
>  create mode 100644 flake.lock
>  create mode 100644 flake.nix
>
> diff --git a/flake.lock b/flake.lock
> new file mode 100644
> index 00000000000..de713ff0da9
> --- /dev/null
> +++ b/flake.lock
> @@ -0,0 +1,60 @@
> +{
> +  "nodes": {
> +    "flake-utils": {
> +      "inputs": {
> +        "systems": "systems"
> +      },
> +      "locked": {
> +        "lastModified": 1694529238,
> +        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
> +        "owner": "numtide",
> +        "repo": "flake-utils",
> +        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
> +        "type": "github"
> +      },
> +      "original": {
> +        "owner": "numtide",
> +        "repo": "flake-utils",
> +        "type": "github"
> +      }
> +    },
> +    "nixpkgs": {
> +      "locked": {
> +        "lastModified": 1696095070,
> +        "narHash": "sha256-iDx02dT+OHYYgaRGJxp2HXvzSHkA9l8/3O8GJB2wttU=",
> +        "owner": "nixos",
> +        "repo": "nixpkgs",
> +        "rev": "1f0e8ac1f9a783c4cfa0515483094eeff4315fe2",
> +        "type": "github"
> +      },
> +      "original": {
> +        "owner": "nixos",
> +        "repo": "nixpkgs",
> +        "type": "github"
> +      }
> +    },
> +    "root": {
> +      "inputs": {
> +        "flake-utils": "flake-utils",
> +        "nixpkgs": "nixpkgs"
> +      }
> +    },
> +    "systems": {
> +      "locked": {
> +        "lastModified": 1681028828,
> +        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
> +        "owner": "nix-systems",
> +        "repo": "default",
> +        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
> +        "type": "github"
> +      },
> +      "original": {
> +        "owner": "nix-systems",
> +        "repo": "default",
> +        "type": "github"
> +      }
> +    }
> +  },
> +  "root": "root",
> +  "version": 7
> +}
> diff --git a/flake.nix b/flake.nix
> new file mode 100644
> index 00000000000..b0ff1915adc
> --- /dev/null
> +++ b/flake.nix
> @@ -0,0 +1,35 @@
> +{
> +  description = "gcc compiler";
> +
> +  inputs = {
> +    nixpkgs.url = "github:nixos/nixpkgs";
> +    flake-utils.url = "github:numtide/flake-utils";
> +  };
> +
> +  outputs = { self, nixpkgs, flake-utils }:
> +    flake-utils.lib.eachDefaultSystem (system:
> +      let pkgs = nixpkgs.legacyPackages.${system};
> +      in {
> +        packages = {
> +          default = pkgs.gnumake;
> +        };
> +        formatter = pkgs.nixpkgs-fmt;
> +
> +        devShell = pkgs.mkShell {
> +          buildInputs = [
> +            pkgs.gnumake
> +            pkgs.gcc13
> +
> +            pkgs.gmp
> +            pkgs.libmpc
> +            pkgs.mpfr
> +            pkgs.isl
> +            pkgs.pkg-config
> +            pkgs.autoconf-archive
> +            pkgs.autoconf
> +            pkgs.automake
> +          ];
> +        };
> +      }
> +    );
> +}
> --
> 2.43.0
>
  
Jeff Law Dec. 5, 2023, 1:07 a.m. UTC | #2
On 12/4/23 18:02, Andrew Pinski wrote:
> On Mon, Dec 4, 2023 at 4:58 PM Vincenzo Palazzo
> <vincenzopalazzodev@gmail.com> wrote:
>>
>> This commit is specifically targeting enhancements in
>> Nix support for GCC development. This initiative stems
>> from the recognized need within our community for a more
>> streamlined and efficient development process when using Nix.
> 
> I think this is wrong place for this.
+1.  I think this is best left to the distros.

jeff
  
Vincenzo Palazzo Dec. 5, 2023, 1:38 a.m. UTC | #3
Ciao all,

>+1.  I think this is best left to the distros.

What do you mean? this is not a package, it is an env shell in order
to build an work on GCC on NixOS.

NixOS has already the packages for GCC

Cheers,

   Vincent.

On Tue, Dec 5, 2023 at 2:07 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 12/4/23 18:02, Andrew Pinski wrote:
> > On Mon, Dec 4, 2023 at 4:58 PM Vincenzo Palazzo
> > <vincenzopalazzodev@gmail.com> wrote:
> >>
> >> This commit is specifically targeting enhancements in
> >> Nix support for GCC development. This initiative stems
> >> from the recognized need within our community for a more
> >> streamlined and efficient development process when using Nix.
> >
> > I think this is wrong place for this.
> +1.  I think this is best left to the distros.
>
> jeff
  
Jeff Law Dec. 5, 2023, 1:54 a.m. UTC | #4
On 12/4/23 18:38, Vincenzo Palazzo wrote:
> Ciao all,
> 
>> +1.  I think this is best left to the distros.
> 
> What do you mean? this is not a package, it is an env shell in order
> to build an work on GCC on NixOS.
> 
Distro build procedures are not something the GCC project generally gets 
involved with.

jeff
  
Vincenzo Palazzo Dec. 5, 2023, 2:01 a.m. UTC | #5
>Distro build procedures are not something the GCC project generally gets
involved with.

I see, but to me, this do not look like a distro build procedure,
because you can use
with any kind of system (OSX/UNIX) by using nix.

I disagree with you just because my patch is not building a package
but is just giving
an agnostic way to develop with GCC. OFC is most useful with NixOs because
it does not have apt or pacman or any other kind of package manager.

Cheers,

   Vincent.

On Tue, Dec 5, 2023 at 2:54 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 12/4/23 18:38, Vincenzo Palazzo wrote:
> > Ciao all,
> >
> >> +1.  I think this is best left to the distros.
> >
> > What do you mean? this is not a package, it is an env shell in order
> > to build an work on GCC on NixOS.
> >
> Distro build procedures are not something the GCC project generally gets
> involved with.
>
> jeff
  
Vincenzo Palazzo Dec. 5, 2023, 2:02 a.m. UTC | #6
However, I understand your point.

Cheers,

   Vincent.

On Tue, Dec 5, 2023 at 3:01 AM Vincenzo Palazzo
<vincenzopalazzodev@gmail.com> wrote:
>
> >Distro build procedures are not something the GCC project generally gets
> involved with.
>
> I see, but to me, this do not look like a distro build procedure,
> because you can use
> with any kind of system (OSX/UNIX) by using nix.
>
> I disagree with you just because my patch is not building a package
> but is just giving
> an agnostic way to develop with GCC. OFC is most useful with NixOs because
> it does not have apt or pacman or any other kind of package manager.
>
> Cheers,
>
>    Vincent.
>
> On Tue, Dec 5, 2023 at 2:54 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
> >
> >
> >
> > On 12/4/23 18:38, Vincenzo Palazzo wrote:
> > > Ciao all,
> > >
> > >> +1.  I think this is best left to the distros.
> > >
> > > What do you mean? this is not a package, it is an env shell in order
> > > to build an work on GCC on NixOS.
> > >
> > Distro build procedures are not something the GCC project generally gets
> > involved with.
> >
> > jeff
  
Eli Schwartz Dec. 5, 2023, 4:25 a.m. UTC | #7
On 12/4/23 9:01 PM, Vincenzo Palazzo wrote:
> On Tue, Dec 5, 2023 at 2:54 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
>> Distro build procedures are not something the GCC project generally gets
>> involved with.
> 
> I see, but to me, this do not look like a distro build procedure,
> because you can use
> with any kind of system (OSX/UNIX) by using nix.


But you can do the same with various other distro build procedures too?

e.g. Gentoo Prefix allows you to install a full-blown gentoo anywhere
you like, "by using portage".

But also by the same token, I can just install pacman or rpm or dpkg on
any system, and use the recipe executor just without requiring a
database of installed packages.


> I disagree with you just because my patch is not building a package
> but is just giving
> an agnostic way to develop with GCC. OFC is most useful with NixOs because
> it does not have apt or pacman or any other kind of package manager.


I'm not entirely sure what this statement means (unless you are saying
that nix isn't a package manager and NixOS doesn't have any package
manager)?

But I'd actually go one step further. It looks like this "flake.nix"
file is the NixOS specific equivalent of a README.md which says "to
install the software, you must first install XX, YY, and ZZ using your
system package manager. Often they will have names such as XX-devel and
suchlike".

Which for GCC would be https://gcc.gnu.org/install/prerequisites.html --
this page actually lists a bunch of things I don't see mentioned in your
"flake.nix" file so I suspect that it won't, in fact, produce a good
development environment for developing GCC.

I don't think it's the job of the GCC maintainers to maintain special
snowflake integrations with niche linux distros, whether those
integrations work or not. But, if it *was* the job of the GCC
maintainers, perhaps it would be better to make a script:

`tools/setup-development-env.sh $distro`

which could abstract away all of this for any distro, not just a niche one.
  
Richard Biener Dec. 5, 2023, 8:59 a.m. UTC | #8
On Tue, Dec 5, 2023 at 5:26 AM Eli Schwartz <eschwartz93@gmail.com> wrote:
>
> On 12/4/23 9:01 PM, Vincenzo Palazzo wrote:
> > On Tue, Dec 5, 2023 at 2:54 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
> >> Distro build procedures are not something the GCC project generally gets
> >> involved with.
> >
> > I see, but to me, this do not look like a distro build procedure,
> > because you can use
> > with any kind of system (OSX/UNIX) by using nix.
>
>
> But you can do the same with various other distro build procedures too?
>
> e.g. Gentoo Prefix allows you to install a full-blown gentoo anywhere
> you like, "by using portage".
>
> But also by the same token, I can just install pacman or rpm or dpkg on
> any system, and use the recipe executor just without requiring a
> database of installed packages.
>
>
> > I disagree with you just because my patch is not building a package
> > but is just giving
> > an agnostic way to develop with GCC. OFC is most useful with NixOs because
> > it does not have apt or pacman or any other kind of package manager.
>
>
> I'm not entirely sure what this statement means (unless you are saying
> that nix isn't a package manager and NixOS doesn't have any package
> manager)?
>
> But I'd actually go one step further. It looks like this "flake.nix"
> file is the NixOS specific equivalent of a README.md which says "to
> install the software, you must first install XX, YY, and ZZ using your
> system package manager. Often they will have names such as XX-devel and
> suchlike".
>
> Which for GCC would be https://gcc.gnu.org/install/prerequisites.html --
> this page actually lists a bunch of things I don't see mentioned in your
> "flake.nix" file so I suspect that it won't, in fact, produce a good
> development environment for developing GCC.
>
> I don't think it's the job of the GCC maintainers to maintain special
> snowflake integrations with niche linux distros, whether those
> integrations work or not. But, if it *was* the job of the GCC
> maintainers, perhaps it would be better to make a script:
>
> `tools/setup-development-env.sh $distro`
>
> which could abstract away all of this for any distro, not just a niche one.

Generally we have various stuff in contrib/, one of it scripts like
gcc_build.  IMHO the flake.nix file (or a script to create it) could be
put there as well.

Richard.

>
> --
> Eli Schwartz
>
  
Vincenzo Palazzo Dec. 5, 2023, 10:35 a.m. UTC | #9
Hi all,

>Generally we have various stuff in contrib/, one of it scripts like
gcc_build.  IMHO the flake.nix file (or a script to create it) could be
put there as well.

I was not sure about that, I will try to see what if I can put in there


>But you can do the same with various other distro build procedures too?
>e.g. Gentoo Prefix allows you to install a full-blown Gentoo anywhere
you like, "by using portage".

With a single difference on Gentoo you are allowed to put stuff in the
global path and use
it from a terminal like `$ pacman -Sy foo`. On nix os you do not,
because the development environment
is used for that.

So all the nice dependencies that gcc required to build can not be
installed in NixOS global pat (e.g libc)
so in NixOS you should define the development environment otherwise
you can do the build. Instead in all
the other systems that you mention you can do.

Please note that the flake.nix does not define how to build gcc, but
just what are the dependencies
that gcc is required in order to contribute to the compiler. In other
words, is you run the flake.nix
on NixOS or any other system you do not have gcc installed on your
system, this is the job of the
distro.

Cheers,

   Vincent.

On Tue, Dec 5, 2023 at 10:03 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Tue, Dec 5, 2023 at 5:26 AM Eli Schwartz <eschwartz93@gmail.com> wrote:
> >
> > On 12/4/23 9:01 PM, Vincenzo Palazzo wrote:
> > > On Tue, Dec 5, 2023 at 2:54 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
> > >> Distro build procedures are not something the GCC project generally gets
> > >> involved with.
> > >
> > > I see, but to me, this do not look like a distro build procedure,
> > > because you can use
> > > with any kind of system (OSX/UNIX) by using nix.
> >
> >
> > But you can do the same with various other distro build procedures too?
> >
> > e.g. Gentoo Prefix allows you to install a full-blown gentoo anywhere
> > you like, "by using portage".
> >
> > But also by the same token, I can just install pacman or rpm or dpkg on
> > any system, and use the recipe executor just without requiring a
> > database of installed packages.
> >
> >
> > > I disagree with you just because my patch is not building a package
> > > but is just giving
> > > an agnostic way to develop with GCC. OFC is most useful with NixOs because
> > > it does not have apt or pacman or any other kind of package manager.
> >
> >
> > I'm not entirely sure what this statement means (unless you are saying
> > that nix isn't a package manager and NixOS doesn't have any package
> > manager)?
> >
> > But I'd actually go one step further. It looks like this "flake.nix"
> > file is the NixOS specific equivalent of a README.md which says "to
> > install the software, you must first install XX, YY, and ZZ using your
> > system package manager. Often they will have names such as XX-devel and
> > suchlike".
> >
> > Which for GCC would be https://gcc.gnu.org/install/prerequisites.html --
> > this page actually lists a bunch of things I don't see mentioned in your
> > "flake.nix" file so I suspect that it won't, in fact, produce a good
> > development environment for developing GCC.
> >
> > I don't think it's the job of the GCC maintainers to maintain special
> > snowflake integrations with niche linux distros, whether those
> > integrations work or not. But, if it *was* the job of the GCC
> > maintainers, perhaps it would be better to make a script:
> >
> > `tools/setup-development-env.sh $distro`
> >
> > which could abstract away all of this for any distro, not just a niche one.
>
> Generally we have various stuff in contrib/, one of it scripts like
> gcc_build.  IMHO the flake.nix file (or a script to create it) could be
> put there as well.
>
> Richard.
>
> >
> > --
> > Eli Schwartz
> >
  
Eli Schwartz Dec. 5, 2023, 12:43 p.m. UTC | #10
On 12/5/23 5:35 AM, Vincenzo Palazzo wrote:
>>> I see, but to me, this do not look like a distro build procedure,
>>> because you can use
>>> with any kind of system (OSX/UNIX) by using nix.
>>
>> But you can do the same with various other distro build procedures too?
>> e.g. Gentoo Prefix allows you to install a full-blown Gentoo anywhere
>> you like, "by using portage".
> 
> With a single difference on Gentoo you are allowed to put stuff in the
> global path and use
> it from a terminal like `$ pacman -Sy foo`. On nix os you do not,
> because the development environment
> is used for that.
> 
> So all the nice dependencies that gcc required to build can not be
> installed in NixOS global pat (e.g libc)
> so in NixOS you should define the development environment otherwise
> you can do the build. Instead in all
> the other systems that you mention you can do.


And yet, it seems your original point was that this doesn't qualify as a
"distro build procedure" because nix isn't specific to NixOS.

Are you backing down from that opinion and deciding that this proposal
is, indeed, after all specific to NixOS and only NixOS and is neither
needed nor used on any other distro?


> Please note that the flake.nix does not define how to build gcc, but
> just what are the dependencies
> that gcc is required in order to contribute to the compiler. In other
> words, is you run the flake.nix
> on NixOS or any other system you do not have gcc installed on your
> system, this is the job of the
> distro.


Its lack of completeness is surely an issue, but not the issue at hand
*here*. Why do you think the lack of completeness is a supporting
argument, rather than an opposing argument?
  
Vincenzo Palazzo Dec. 11, 2023, 4:10 p.m. UTC | #11
Hi all,

>Are you backing down from that opinion and deciding that this proposal
is, indeed, after all specific to NixOS and only NixOS and is neither
needed nor used on any other distro?

I may be misreading the conversation, so let's restart it.

Why should my RFC be inside the distro's repository? What makes this a distro
build package? and not a developer configuration for building a
development environment?

Cheers,

   Vincent.

On Tue, Dec 5, 2023 at 1:43 PM Eli Schwartz <eschwartz93@gmail.com> wrote:
>
> On 12/5/23 5:35 AM, Vincenzo Palazzo wrote:
> >>> I see, but to me, this do not look like a distro build procedure,
> >>> because you can use
> >>> with any kind of system (OSX/UNIX) by using nix.
> >>
> >> But you can do the same with various other distro build procedures too?
> >> e.g. Gentoo Prefix allows you to install a full-blown Gentoo anywhere
> >> you like, "by using portage".
> >
> > With a single difference on Gentoo you are allowed to put stuff in the
> > global path and use
> > it from a terminal like `$ pacman -Sy foo`. On nix os you do not,
> > because the development environment
> > is used for that.
> >
> > So all the nice dependencies that gcc required to build can not be
> > installed in NixOS global pat (e.g libc)
> > so in NixOS you should define the development environment otherwise
> > you can do the build. Instead in all
> > the other systems that you mention you can do.
>
>
> And yet, it seems your original point was that this doesn't qualify as a
> "distro build procedure" because nix isn't specific to NixOS.
>
> Are you backing down from that opinion and deciding that this proposal
> is, indeed, after all specific to NixOS and only NixOS and is neither
> needed nor used on any other distro?
>
>
> > Please note that the flake.nix does not define how to build gcc, but
> > just what are the dependencies
> > that gcc is required in order to contribute to the compiler. In other
> > words, is you run the flake.nix
> > on NixOS or any other system you do not have gcc installed on your
> > system, this is the job of the
> > distro.
>
>
> Its lack of completeness is surely an issue, but not the issue at hand
> *here*. Why do you think the lack of completeness is a supporting
> argument, rather than an opposing argument?
>
>
> --
> Eli Schwartz
>
  

Patch

diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000000..de713ff0da9
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,60 @@ 
+{
+  "nodes": {
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1696095070,
+        "narHash": "sha256-iDx02dT+OHYYgaRGJxp2HXvzSHkA9l8/3O8GJB2wttU=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "1f0e8ac1f9a783c4cfa0515483094eeff4315fe2",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000000..b0ff1915adc
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,35 @@ 
+{
+  description = "gcc compiler";
+
+  inputs = {
+    nixpkgs.url = "github:nixos/nixpkgs";
+    flake-utils.url = "github:numtide/flake-utils";
+  };
+
+  outputs = { self, nixpkgs, flake-utils }:
+    flake-utils.lib.eachDefaultSystem (system:
+      let pkgs = nixpkgs.legacyPackages.${system};
+      in {
+        packages = {
+          default = pkgs.gnumake;
+        };
+        formatter = pkgs.nixpkgs-fmt;
+
+        devShell = pkgs.mkShell {
+          buildInputs = [
+            pkgs.gnumake
+            pkgs.gcc13
+
+            pkgs.gmp
+            pkgs.libmpc
+            pkgs.mpfr
+            pkgs.isl
+            pkgs.pkg-config
+            pkgs.autoconf-archive
+            pkgs.autoconf
+            pkgs.automake
+          ];
+        };
+      }
+    );
+}