Skip to content

Project Layout

Instead of configuring everything in flake.nix, Conflake can derive outputs according to your project directory structure.

Considering the following directory structure, from examples/demo:

examples/demo/
├── .editorconfig
├── flake.nix
└── nix/
    ├── darwin/
    │   └── hostname.nix
    ├── darwinModules/
    │   └── default.nix
    ├── home/
    │   └── username.nix
    ├── homeModules/
    │   └── default.nix
    ├── nixos/
    │   └── hostname.nix
    ├── nixosModules/
    │   └── default.nix
    ├── packages/
    │   └── default.nix
    └── templates/
        └── default/
            └── flake.nix

It will result a flake output like:

git+file:///tmp/conflake?dir=examples/demo
├───checks
│   ├───aarch64-darwin
│   │   ├───editorconfig: derivation 'check-editorconfig'
│   │   ├───formatting: derivation 'check-formatting'
│   │   ├───packages-default: derivation 'check-packages-default'
│   │   └───statix: derivation 'check-statix'
│   ├───aarch64-linux
│   │   ├───editorconfig: derivation 'check-editorconfig'
│   │   ├───formatting: derivation 'check-formatting'
│   │   ├───packages-default: derivation 'check-packages-default'
│   │   └───statix: derivation 'check-statix'
│   ├───x86_64-darwin
│   │   ├───editorconfig: derivation 'check-editorconfig'
│   │   ├───formatting: derivation 'check-formatting'
│   │   ├───packages-default: derivation 'check-packages-default'
│   │   └───statix: derivation 'check-statix'
│   └───x86_64-linux
│       ├───editorconfig: derivation 'check-editorconfig'
│       ├───formatting: derivation 'check-formatting'
│       ├───home-username: derivation 'check-home-username'
│       ├───nixos-hostname: derivation 'check-nixos-nixos-hostname'
│       ├───packages-default: derivation 'check-packages-default'
│       └───statix: derivation 'check-statix'
├───darwinConfigurations: unknown
├───darwinModules: unknown
├───devShells
│   ├───aarch64-darwin
│   │   └───default: development environment 'nix-shell'
│   ├───aarch64-linux
│   │   └───default: development environment 'nix-shell'
│   ├───x86_64-darwin
│   │   └───default: development environment 'nix-shell'
│   └───x86_64-linux
│       └───default: development environment 'nix-shell'
├───formatter
│   ├───aarch64-darwin: package 'formatter'
│   ├───aarch64-linux: package 'formatter'
│   ├───x86_64-darwin: package 'formatter'
│   └───x86_64-linux: package 'formatter'
├───homeConfigurations: unknown
├───homeModules: unknown
├───nixosConfigurations
│   └───hostname: NixOS configuration
├───nixosModules
│   └───default: NixOS module
├───overlays
│   └───default: Nixpkgs overlay
├───packages
│   ├───aarch64-darwin
│   │   └───default: package 'hello-2.12.1'
│   ├───aarch64-linux
│   │   └───default: package 'hello-2.12.1'
│   ├───x86_64-darwin
│   │   └───default: package 'hello-2.12.1'
│   └───x86_64-linux
│       └───default: package 'hello-2.12.1'
└───templates
    └───default: template: default
json
{
  "checks": {
    "aarch64-darwin": {
      "editorconfig": {
        "description": "",
        "name": "check-editorconfig",
        "type": "derivation"
      },
      "formatting": {
        "description": "",
        "name": "check-formatting",
        "type": "derivation"
      },
      "packages-default": {
        "description": "",
        "name": "check-packages-default",
        "type": "derivation"
      },
      "statix": {
        "description": "",
        "name": "check-statix",
        "type": "derivation"
      }
    },
    "aarch64-linux": {
      "editorconfig": {
        "description": "",
        "name": "check-editorconfig",
        "type": "derivation"
      },
      "formatting": {
        "description": "",
        "name": "check-formatting",
        "type": "derivation"
      },
      "packages-default": {
        "description": "",
        "name": "check-packages-default",
        "type": "derivation"
      },
      "statix": {
        "description": "",
        "name": "check-statix",
        "type": "derivation"
      }
    },
    "x86_64-darwin": {
      "editorconfig": {
        "description": "",
        "name": "check-editorconfig",
        "type": "derivation"
      },
      "formatting": {
        "description": "",
        "name": "check-formatting",
        "type": "derivation"
      },
      "packages-default": {
        "description": "",
        "name": "check-packages-default",
        "type": "derivation"
      },
      "statix": {
        "description": "",
        "name": "check-statix",
        "type": "derivation"
      }
    },
    "x86_64-linux": {
      "editorconfig": {
        "description": "",
        "name": "check-editorconfig",
        "type": "derivation"
      },
      "formatting": {
        "description": "",
        "name": "check-formatting",
        "type": "derivation"
      },
      "home-username": {
        "description": "",
        "name": "check-home-username",
        "type": "derivation"
      },
      "nixos-hostname": {
        "description": "",
        "name": "check-nixos-nixos-hostname",
        "type": "derivation"
      },
      "packages-default": {
        "description": "",
        "name": "check-packages-default",
        "type": "derivation"
      },
      "statix": {
        "description": "",
        "name": "check-statix",
        "type": "derivation"
      }
    }
  },
  "darwinConfigurations": {
    "type": "unknown"
  },
  "darwinModules": {
    "type": "unknown"
  },
  "devShells": {
    "aarch64-darwin": {
      "default": {
        "description": "",
        "name": "nix-shell",
        "type": "derivation"
      }
    },
    "aarch64-linux": {
      "default": {
        "description": "",
        "name": "nix-shell",
        "type": "derivation"
      }
    },
    "x86_64-darwin": {
      "default": {
        "description": "",
        "name": "nix-shell",
        "type": "derivation"
      }
    },
    "x86_64-linux": {
      "default": {
        "description": "",
        "name": "nix-shell",
        "type": "derivation"
      }
    }
  },
  "formatter": {
    "aarch64-darwin": {
      "description": "",
      "name": "formatter",
      "type": "derivation"
    },
    "aarch64-linux": {
      "description": "",
      "name": "formatter",
      "type": "derivation"
    },
    "x86_64-darwin": {
      "description": "",
      "name": "formatter",
      "type": "derivation"
    },
    "x86_64-linux": {
      "description": "",
      "name": "formatter",
      "type": "derivation"
    }
  },
  "homeConfigurations": {
    "type": "unknown"
  },
  "homeModules": {
    "type": "unknown"
  },
  "nixosConfigurations": {
    "hostname": {
      "type": "nixos-configuration"
    }
  },
  "nixosModules": {
    "default": {
      "type": "nixos-module"
    }
  },
  "overlays": {
    "default": {
      "type": "nixpkgs-overlay"
    }
  },
  "packages": {
    "aarch64-darwin": {
      "default": {
        "description": "Program that produces a familiar, friendly greeting",
        "name": "hello-2.12.1",
        "type": "derivation"
      }
    },
    "aarch64-linux": {
      "default": {
        "description": "Program that produces a familiar, friendly greeting",
        "name": "hello-2.12.1",
        "type": "derivation"
      }
    },
    "x86_64-darwin": {
      "default": {
        "description": "Program that produces a familiar, friendly greeting",
        "name": "hello-2.12.1",
        "type": "derivation"
      }
    },
    "x86_64-linux": {
      "default": {
        "description": "Program that produces a familiar, friendly greeting",
        "name": "hello-2.12.1",
        "type": "derivation"
      }
    }
  },
  "templates": {
    "default": {
      "description": "default",
      "type": "template"
    }
  }
}

Notice that darwin, home and nixos are shorthand mapping to darwinConfigurations, homeConfigurations and nixosConfigurations respectively.