├── LICENSE ├── README.md ├── default └── flake.nix └── flake.nix /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ultimate guide video repo 2 | 3 | ## search for packages 4 | 5 | https://search.nixos.org/packages 6 | 7 | ## initializing flake 8 | ```bash 9 | $ cd /etc/nixos 10 | $ sudo nix flake init --template github:vimjoyer/flake-starter-config 11 | ``` 12 | 13 | ## rebuilding with flakes enabled 14 | 15 | ```bash 16 | $ sudo nixos-rebuild switch --flake /etc/nixos/#nixos 17 | ``` 18 | 19 | ## generating home.nix 20 | ```bash 21 | $ nix run home-manager/master -- init && \ 22 | sudo cp ~/.config/home-manager/home.nix /etc/nixos/ 23 | ``` 24 | 25 | ## home-manager option 26 | ```nix 27 | home-manager = { 28 | # also pass inputs to home-manager modules 29 | extraSpecialArgs = {inherit inputs;}; 30 | users = { 31 | "username" = import ./home.nix; 32 | }; 33 | }; 34 | ``` 35 | 36 | ## example module / main-user.nix 37 | ```nix 38 | { lib, config, pkgs, ... }: 39 | 40 | let 41 | cfg = config.main-user; 42 | in 43 | { 44 | options.main-user = { 45 | enable 46 | = lib.mkEnableOption "enable user module"; 47 | 48 | userName = lib.mkOption { 49 | default = "mainuser"; 50 | description = '' 51 | username 52 | ''; 53 | }; 54 | }; 55 | 56 | config = lib.mkIf cfg.enable { 57 | users.users.${cfg.userName} = { 58 | isNormalUser = true; 59 | initialPassword = "12345"; 60 | description = "main user"; 61 | shell = pkgs.zsh; 62 | }; 63 | }; 64 | } 65 | ``` 66 | 67 | ## example project structure 68 | 69 | ``` 70 |  flake.nix 71 | 72 |  flake.lock 73 | 74 |  modules/ 75 | 76 |  nixos/ 77 | 78 |  nvidia.nix 79 | 80 |  home-manager/ 81 | 82 |  terminals/ 83 | 84 |  default.nix 85 | 86 |  kitty.nix 87 | 88 |  alacritty.nix 89 | 90 |  hosts/ 91 | 92 |  default/ 93 | 94 |  configuration.nix 95 | 96 |  hardware-configuration.nix 97 | 98 |  home.nix 99 | ``` 100 | 101 | ## adding standalone home-manager configurations 102 | ```nix 103 | homeConfigurations.homeConfigName = inputs.home-manager.lib.homeManagerConfiguration { 104 | # Specify the host architecture 105 | pkgs = nixpkgs.legacyPackages."x86_64-linux"; 106 | 107 | # Specify your home configuration modules here, for example, 108 | # the path to your home.nix. 109 | modules = [ ./home.nix ]; 110 | 111 | extraSpecialArgs = { inherit inputs; }; 112 | }; 113 | ``` 114 | This alternative approach can be used on any machine that supports nix. 115 | 116 | ```bash 117 | home-manager switch --flake /etc/nixos/#homeConfigName 118 | ``` 119 | -------------------------------------------------------------------------------- /default/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Nixos config flake"; 3 | 4 | inputs = { 5 | nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 6 | 7 | # home-manager = { 8 | # url = "github:nix-community/home-manager"; 9 | # inputs.nixpkgs.follows = "nixpkgs"; 10 | # }; 11 | }; 12 | 13 | outputs = { self, nixpkgs, ... }@inputs: { 14 | # use "nixos", or your hostname as the name of the configuration 15 | # it's a better practice than "default" shown in the video 16 | nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { 17 | specialArgs = {inherit inputs;}; 18 | modules = [ 19 | ./configuration.nix 20 | # inputs.home-manager.nixosModules.default 21 | ]; 22 | }; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "A simple flake with 1 template"; 3 | 4 | outputs = { self }: { 5 | 6 | templates = { 7 | 8 | example = { 9 | path = ./default; 10 | description = "Basic NixOS config flake"; 11 | }; 12 | 13 | }; 14 | 15 | defaultTemplate = self.templates.example; 16 | 17 | }; 18 | } 19 | --------------------------------------------------------------------------------