From aebb57e4be5f3a7a5e18a82acd18e5846642764a Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Wed, 30 Aug 2023 15:07:38 -0400 Subject: [PATCH] feat: Added new default template that is `devShell` based. --- templates/default/.envrc | 1 + templates/default/.gitignore | 5 ++++- templates/default/flake.nix | 30 +++++++++++------------------- templates/vagrant/.gitignore | 1 + templates/vagrant/Vagrantfile | 32 ++++++++++++++++++++++++++++++++ templates/vagrant/flake.nix | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 templates/default/.envrc create mode 100644 templates/vagrant/.gitignore create mode 100644 templates/vagrant/Vagrantfile create mode 100644 templates/vagrant/flake.nix diff --git a/templates/default/.envrc b/templates/default/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/default/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/default/.gitignore b/templates/default/.gitignore index 997ca2f..1f04325 100644 --- a/templates/default/.gitignore +++ b/templates/default/.gitignore @@ -1 +1,4 @@ -.vagrant \ No newline at end of file +.direnv +.vagrant +node_modules +vendor diff --git a/templates/default/flake.nix b/templates/default/flake.nix index 02d1699..605f0ee 100644 --- a/templates/default/flake.nix +++ b/templates/default/flake.nix @@ -11,24 +11,16 @@ outputs = { self, flake-utils, nixpkgs, sbrow }: flake-utils.lib.eachSystem flake-utils.lib.allSystems - (system: { - formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; - }) // { - nixosModules.default = { config, pkgs, ... }: { - config = { - environment.systemPackages = [ pkgs.git ]; - /* Your config here */ - }; - }; + (system: + let pkgs = nixpkgs.legacyPackages.${system}; in + { + formatter = pkgs.nixpkgs-fmt; - # A Vagrant box for testing - nixosConfigurations.vagrant = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - (nixpkgs + "/nixos/modules/virtualisation/virtualbox-image.nix") - sbrow.nixosModules.vagrant - self.nixosModules.default - ]; - }; - }; + devShells.default = pkgs.mkShell + { + buildInputs = with pkgs; [ + # Your packages here + ]; + }; + }); } diff --git a/templates/vagrant/.gitignore b/templates/vagrant/.gitignore new file mode 100644 index 0000000..997ca2f --- /dev/null +++ b/templates/vagrant/.gitignore @@ -0,0 +1 @@ +.vagrant \ No newline at end of file diff --git a/templates/vagrant/Vagrantfile b/templates/vagrant/Vagrantfile new file mode 100644 index 0000000..fce8d60 --- /dev/null +++ b/templates/vagrant/Vagrantfile @@ -0,0 +1,32 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "nixos" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # config.vm.network "forwarded_port", guest: 80, host: 80 + # config.vm.network "forwarded_port", guest: 443, host: 443 + config.vm.network "private_network", ip: "192.168.56.44", auto_config: false + # config.vm.network "public_network" + + config.vm.provider "virtualbox" do |vb| + # Display the VirtualBox GUI when booting the machine + vb.gui = false + + # Customize the amount of memory on the VM: + # vb.memory = 4 * 1024 + + # vb.cpus = 2; + end + + config.vm.provision "shell", inline: <<-SHELL + # nix develop 'nixpkgs#git' --command "sudo nixos-rebuild switch --flake /vagrant#vagrant" + nix-shell -p git --command "sudo nixos-rebuild switch --flake /vagrant#vagrant" + SHELL + end + \ No newline at end of file diff --git a/templates/vagrant/flake.nix b/templates/vagrant/flake.nix new file mode 100644 index 0000000..02d1699 --- /dev/null +++ b/templates/vagrant/flake.nix @@ -0,0 +1,34 @@ +{ + description = "A very basic flake"; + + inputs = { + # nixpkgs.url = "github:NixOS/nixpkgs/23.05"; + + sbrow.url = "github:sbrow/nix"; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, flake-utils, nixpkgs, sbrow }: + flake-utils.lib.eachSystem flake-utils.lib.allSystems + (system: { + formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + }) // { + nixosModules.default = { config, pkgs, ... }: { + config = { + environment.systemPackages = [ pkgs.git ]; + /* Your config here */ + }; + }; + + # A Vagrant box for testing + nixosConfigurations.vagrant = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + (nixpkgs + "/nixos/modules/virtualisation/virtualbox-image.nix") + sbrow.nixosModules.vagrant + self.nixosModules.default + ]; + }; + }; +}