diff --git a/flake.nix b/flake.nix index 83869bd..842f54b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,165 +1,171 @@ { description = "A collection of flake templates"; - outputs = { self }: { - - templates = { - - trivial = { - path = ./trivial; - description = "A very basic flake"; - }; - - simpleContainer = { - path = ./simple-container; - description = "A NixOS container running apache-httpd"; - }; - - python = { - path = ./python; - description = "Python template, using poetry2nix"; - welcomeText = '' - # Getting started - - Run `nix develop` - - Run `poetry run python -m sample_package` - ''; - }; - - rust = { - path = ./rust; - description = "Rust template, using Naersk"; - }; - - bash-hello = { - path = ./bash-hello; - description = "An over-engineered Hello World in bash"; - }; - - c-hello = { - path = ./c-hello; - description = "An over-engineered Hello World in C"; - }; - - ruby = { - path = ./ruby; - description = "Flake for building ruby gems" ; - welcomeText = '' - # Simple Ruby Gem Template - ## Intended usage - The intended usage of this flake is to facilitate building ruby gems - - ## More info - - [Ruby language](https://www.ruby-lang.org/) - - [Ruby in the NixOS manual](https://nixos.org/manual/nixpkgs/stable/#sec-language-ruby) - ''; - }; - - rust-web-server = { - path = ./rust-web-server; - description = "A Rust web server including a NixOS module"; - }; - - compat = { - path = ./compat; - description = "A default.nix and shell.nix for backward compatibility with Nix installations that don't support flakes"; - }; - - haskell-hello = { - path = ./haskell-hello; - description = "A Hello World in Haskell with one dependency"; - }; - - hercules-ci = { - path = ./hercules-ci; - description = "An example for Hercules-CI, containing only the necessary attributes for adding to your project."; - }; - - full = { - path = ./full; - description = "A template that shows all standard flake outputs"; - welcomeText = '' - You just created a template that will show you all standard flake outputs. - - Read more about it here: - - https://github.com/NixOS/templates/tree/master/full - ''; - }; - - pandoc-xelatex = { - path = ./pandoc-xelatex; - description = "A report built with Pandoc, XeLaTex and a custom font"; - }; - - latexmk = { - path = ./latexmk; - description = "A simple LaTeX template for writing documents with latexmk"; - }; - - go-hello = { - path = ./go-hello; - description = "A simple Go package"; - }; - - empty = { - path = ./empty; - description = "A flake with no outputs"; - }; - - haskell-nix = { - path = ./haskell.nix; - description = "An haskell.nix template using hix"; - welcomeText = '' - You just created an haskell.nix template using hix. Read more about it here: - https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html - ''; - }; - - haskell-flake = { - path = ./haskell-flake; - description = "A haskell-flake template"; - welcomeText = '' - You just created a haskell-flake template. - See the README or https://github.com/srid/haskell-flake. - ''; - }; - - utils-generic = { - path = ./utils-generic; - description = "Simple, all-rounder template with utils enabled and devShell populated"; - }; - - dotnet = { - path = ./dotnet; - description = "A .NET application and test project"; - }; - - typescript-pnpm = { - path = ./typescript/pnpm; - description = "A template combining a node webserver and a dev environment - for frontend typescript development"; - welcomeText = '' - # Getting Started - - run `nix develop` to enter the development environment - - run `pnpm install` to install the packaged - - run `pnpm start` to open a live reloading website - ''; - }; - - typescript-p5js = { - path = ./typescript/pnpm-p5js; - description = "A template combining a node webserver and a dev environment - for frontend typescript development"; - welcomeText = '' - # Getting Started - - run `nix develop` to enter the development environment - - run `pnpm install` to install the packaged - - run `pnpm start` to open a live reloading website - ''; - }; + outputs = + { self }: + { + templates = { + default = self.templates.multi-system; + + multi-system = { + path = ./multi-system; + description = "A multi-system flake"; + welcomeText = '' + # Getting started + - Run `nix develop` to enter the default development environment + - Run `nix build` to build the `hello` package from Nixpkgs + ''; + }; + + trivial = { + path = ./trivial; + description = "A very basic flake"; + }; + + simpleContainer = { + path = ./simple-container; + description = "A NixOS container running apache-httpd"; + }; + + python = { + path = ./python; + description = "Python template, using poetry2nix"; + welcomeText = '' + # Getting started + - Run `nix develop` + - Run `poetry run python -m sample_package` + ''; + }; + + rust = { + path = ./rust; + description = "Rust template, using Naersk"; + }; + + bash-hello = { + path = ./bash-hello; + description = "An over-engineered Hello World in bash"; + }; + + c-hello = { + path = ./c-hello; + description = "An over-engineered Hello World in C"; + }; + + ruby = { + path = ./ruby; + description = "Flake for building ruby gems"; + welcomeText = '' + # Simple Ruby Gem Template + ## Intended usage + The intended usage of this flake is to facilitate building ruby gems + + ## More info + - [Ruby language](https://www.ruby-lang.org/) + - [Ruby in the NixOS manual](https://nixos.org/manual/nixpkgs/stable/#sec-language-ruby) + ''; + }; + + rust-web-server = { + path = ./rust-web-server; + description = "A Rust web server including a NixOS module"; + }; + + compat = { + path = ./compat; + description = "A default.nix and shell.nix for backward compatibility with Nix installations that don't support flakes"; + }; + + haskell-hello = { + path = ./haskell-hello; + description = "A Hello World in Haskell with one dependency"; + }; + + hercules-ci = { + path = ./hercules-ci; + description = "An example for Hercules-CI, containing only the necessary attributes for adding to your project."; + }; + + full = { + path = ./full; + description = "A template that shows all standard flake outputs"; + welcomeText = '' + You just created a template that will show you all standard flake outputs. + + Read more about it here: + + https://github.com/NixOS/templates/tree/master/full + ''; + }; + + pandoc-xelatex = { + path = ./pandoc-xelatex; + description = "A report built with Pandoc, XeLaTex and a custom font"; + }; + + latexmk = { + path = ./latexmk; + description = "A simple LaTeX template for writing documents with latexmk"; + }; + + go-hello = { + path = ./go-hello; + description = "A simple Go package"; + }; + + empty = { + path = ./empty; + description = "A flake with no outputs"; + }; + + haskell-nix = { + path = ./haskell.nix; + description = "An haskell.nix template using hix"; + welcomeText = '' + You just created an haskell.nix template using hix. Read more about it here: + https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html + ''; + }; + + haskell-flake = { + path = ./haskell-flake; + description = "A haskell-flake template"; + welcomeText = '' + You just created a haskell-flake template. + See the README or https://github.com/srid/haskell-flake. + ''; + }; + + utils-generic = self.templates.multi-system; + + dotnet = { + path = ./dotnet; + description = "A .NET application and test project"; + }; + + typescript-pnpm = { + path = ./typescript/pnpm; + description = "A template combining a Node.js webserver and a dev environment for frontend TypeScript development"; + welcomeText = '' + # Getting Started + - run `nix develop` to enter the development environment + - run `pnpm install` to install the packaged + - run `pnpm start` to open a live reloading website + ''; + }; + + typescript-p5js = { + path = ./typescript/pnpm-p5js; + description = "A template combining a Node.js webserver and a dev environment for frontend TypeScript development"; + welcomeText = '' + # Getting Started + - run `nix develop` to enter the development environment + - run `pnpm install` to install the packaged + - run `pnpm start` to open a live reloading website + ''; + }; + }; + + defaultTemplate = self.templates.trivial; }; - - defaultTemplate = self.templates.trivial; - - }; } diff --git a/multi-system/flake.nix b/multi-system/flake.nix new file mode 100644 index 0000000..b163cf1 --- /dev/null +++ b/multi-system/flake.nix @@ -0,0 +1,50 @@ +{ + description = "A very basic flake"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + outputs = + { self, nixpkgs }: + let + # Systems supported by this flake + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + # A helper function for specifying per-system outputs + forEachSupportedSystem = + f: + nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import nixpkgs { inherit system; }; + } + ); + in + { + # Development environments + devShells = forEachSupportedSystem ( + { pkgs }: + { + default = pkgs.mkShell { + packages = with pkgs; [ + # Add development environment packages here + ]; + }; + } + ); + + # Package outputs + packages = forEachSupportedSystem ( + { pkgs }: + { + # Build this by running `nix build`, `nix build .`, or `nix build .#default` + default = pkgs.hello; + # Build this by running `nix build .#hello` + hello = pkgs.hello; + } + ); + }; +} diff --git a/trivial/flake.nix b/trivial/flake.nix index c7a9a1c..7e6ccbb 100644 --- a/trivial/flake.nix +++ b/trivial/flake.nix @@ -5,11 +5,13 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; - outputs = { self, nixpkgs }: { + outputs = + { self, nixpkgs }: + { - packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; + packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; - packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + packages.x86_64-linux.default = self.packages.x86_64-linux.hello; - }; + }; } diff --git a/utils-generic/.envrc b/utils-generic/.envrc deleted file mode 100644 index 3550a30..0000000 --- a/utils-generic/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake diff --git a/utils-generic/flake.nix b/utils-generic/flake.nix deleted file mode 100644 index 66da2a0..0000000 --- a/utils-generic/flake.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ - inputs = { - utils.url = "github:numtide/flake-utils"; - }; - outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - devShell = pkgs.mkShell { - buildInputs = with pkgs; [ - ]; - }; - } - ); -}