JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.61k stars 2.41k forks source link

DSC Resource for oh-my-posh #4340

Open denelon opened 1 year ago

denelon commented 1 year ago

Code of Conduct

What would you like to see changed/added?

Suggested new feature or improvement

I'd like to be able to use the WinGet Configuration feature to configure oh-my-posh.

In the future when DSC v3 supports the "export" behavior, this could also be used as a part of the export a configuration scenario.

Scenario

I want to set up a new device and have the ability to configure oh-my-posh with WinGet Configure or by selecting the configuration in Dev Home.

Additional details

I would expect the Microsoft.WinGet.DSC resource would be used to install oh-my-posh on my machine. Then as a dependency I'd like to be able to use a DSC resource to configure oh-my-posh the way I like it.

oh-my-posh
denelon commented 1 year ago

As soon as we get this working, we should put a sample configuration at Dev Home.

nopeless commented 1 year ago

This looks like an interesting feature, but I don't see how this can drastically reduce time setting up oh my posh

denelon commented 1 year ago

It's not aiming to drastically reduce time. It's more about automating the setup and configuration.

nopeless commented 1 year ago

I didn't notice you are the product manager for winget

Good luck with the PR, and thanks for the work 👍

JanDeDobbeleer commented 1 year ago

@denelon I've been trying to give this a go and I'm blocked on the first step. Maybe it's something obvious, or there are dependencies I don't have which results in a bad user experience.

Sample configuration file:

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: ohmyposh
      directives:
        description: Install Oh My Posh
        allowPrerelease: true
      settings:
        id: JanDeDobbeleer.OhMyPosh
        source: winget
  configurationVersion: 0.2.0

Outcome:

image

denelon commented 10 months ago

@JanDeDobbeleer I'm so sorry for a very late reply. I didn't see your reply, and was just checking in.

I wasn't able to repro the problem you encountered.

ohmyposh
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: ohmyposh
      directives:
        description: Install Oh My Posh
        allowPrerelease: true
      settings:
        id: JanDeDobbeleer.OhMyPosh
        source: winget
  configurationVersion: 0.2.0
denelon commented 10 months ago

We're adding sample configurations to Dev Home.

We're currently working on improving the documentation and providing additional samples for specific DSC Resources. I'd love to add a sample for configuring oh-my-posh. It's one of the very first things I do when I'm setting up a new device.

I'll be building a configuration (as will several others) to demonstrate everything I like to install and configure on Windows so share. We'll be adding a README with links to several examples for MSFT contributors to capture gaps in WinGet configuration and to share our progress.

I think it would be awesome to share this in my future presentations. 😊

JanDeDobbeleer commented 9 months ago

@denelon I still have that error. It just doesn't work on my machine. I can't work on this until someone can tell me how to solve this. I'll create a bug at winget.

2024-02-11 16:04:33.217 [CONF] Configuration unit WinGetPackage[ohmyposh] failed with code 0x8a15c105 and error message:
Could not load file or assembly 'Microsoft.WinGet.Client.Engine, Version=1.21.0.0, Culture=neutral, PublicKeyToken=null'. Uncaught exception during type initialization. (0x80131534)
Microsoft.Management.Configuration.Processor.Exceptions.InvokeDscResourceException: Failed when calling `Test` for resource: WinGetPackage [Microsoft.WinGet.DSC] Message: 'Could not load file or assembly 'Microsoft.WinGet.Client.Engine, Version=1.21.0.0, Culture=neutral, PublicKeyToken=null'. Uncaught exception during type initialization. (0x80131534)
'
   at Microsoft.Management.Configuration.Processor.DscModule.DscModuleV2.InvokeTestResource(PowerShell pwsh, ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Runspaces.HostedEnvironment.InvokeTestResource(ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Unit.ConfigurationUnitProcessor.TestSettings()
2024-02-11 16:04:33.229 [CLI ] Terminating context: 0x8a15c005 at C:\__w\1\s\external\pkg\src\AppInstallerCLICore\Workflows\ConfigurationFlow.cpp:3f9
joadoumie commented 9 months ago

@ryfu-msft - any chance you can help debug? I'd love to have this feature added to my setup script.

JanDeDobbeleer commented 9 months ago

@joadoumie @denelon I found that dll in the PowerShell module, but my .NET skills are ancient and I couldn't add this where winget expects them. Although I'd argue this shouldn't be my experience 😅

EDIT: I didn't validate the version though, will have a look at that as well.

ryfu-msft commented 9 months ago

@JanDeDobbeleer, can you repro this again but with the --verbose flag and then post the logs from that run either here or in the winget-cli issue that you opened. That will give us a bit more info.

JanDeDobbeleer commented 9 months ago

@ryfu-msft see https://github.com/microsoft/winget-cli/issues/4160#issuecomment-1954912097

joadoumie commented 9 months ago

@JanDeDobbeleer - I was curious what it would take to get this done, so I started playing around with it today. If you're interested and it's helpful, I can share my WIP first-draft. Right now, it only is working for pwsh setup because that's all I'm honestly familiar with.

JanDeDobbeleer commented 9 months ago

@joadoumie you can always share, but as I'm having issues getting this to work I'm not including this until I can also test and support it.

joadoumie commented 9 months ago

@JanDeDobbeleer - totally makes sense! I just got curious what it would take so it's been fun to play around with it. I also likely haven't accounted for a lot of things I'd imagine. I'll clean it up a little more than maybe just open a draft PR in the repo for comparison in the future whenever you're able to fix the issue & test/support.

denelon commented 5 months ago

It looks like the issue "might" be related to running Windows on a Mac using Parallels. I'll need to see if I can reproduce this on another device. If anyone else can confirm, that would also be sufficient for us to see if we can make some progress for that particular device/OS configuration.